From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Joseph Shraibman <jks(at)selectacast(dot)net> |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: index question |
Date: | 2001-10-19 01:39:30 |
Message-ID: | 9109.1003455570@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Joseph Shraibman <jks(at)selectacast(dot)net> writes:
> Lets say I have a table with columns a and b. I want to do a query like
> SELECT count(distinct b) WHERE a = 2;
> Should I have an index on a or an index on (a,b)?
At present, only an index on a will help any. Our implementation of
count(distinct ...) isn't bright enough to make use of indexes.
Now an index on (a,b) can substitute for an index on a, so if you
have other queries that could use both columns of the (a,b) index
then it might be worth making that instead of an index on a.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Douglas Rafael da Silva | 2001-10-19 01:45:00 | Diferent databases on same query... |
Previous Message | Tom Lane | 2001-10-19 01:30:56 | Re: When will vacuum go away? |