"David Witham" <[EMAIL PROTECTED]> writes:
> I understand that selecting count(*) will involve a scan at some
> stage, but I was surprised that the index wasn't used in the >= case,
> but was used in the between case.
Given the estimated row counts in your examples, the planner's choices
are not s
magnitude too
low. However, it used the index I wanted and the >= case didn't.
Regards,
David
-Original Message-
From: Tom Lane [mailto:[EMAIL PROTECTED]
Sent: Friday, 13 February 2004 16:38
To: David Witham
Cc: [EMAIL PROTECTED]
Subject: Re: [SQL] Index question
"David
Hi all,
I have a table with around 3M records in it and a few indexes on it. One of them is on
the day column. I get 10-20K new records a day. After running ANALYSE in psql I tried
the following queries:
buns=# explain select count(*) from cdr where day >= '20040127';
Joseph Shraibman <[EMAIL PROTECTED]> 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
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)?
--
Joseph Shraibman
[EMAIL PROTECTED]
Increase signal to noise ratio. http://www.targabot.com
---(end of br