Index usage vs large repetitions of key - Mailing list pgsql-general

From Francisco Reyes
Subject Index usage vs large repetitions of key
Date
Msg-id 20020504160120.B66845-100000@zoraida.natserv.net
Whole thread Raw
Responses Re: Index usage vs large repetitions of key
List pgsql-general
I have a table with a "year" column.
A count grouped by year is as follows:
=> select year, count(*) from ystats group by year;
 year | count
------+--------
 1992 | 367191
 1993 | 341324
 1994 | 324867
 1995 | 314674
 1996 | 307149
 1997 | 303540
 1998 | 298040
 1999 | 300269
 2000 | 302648
 2001 | 305797
 2002 | 127445
(11 rows)

I created an index by year, but it never seems to get used, not even with
"set enable_seqscan to off;"

I have numerous queries I do against this table that only need to acces
one or two years.

I am making the wrong assumption here that doing an index scan would be
significantly more efficient? If so how do I help the optimizer see this?


pgsql-general by date:

Previous
From: Jeffrey Baker
Date:
Subject: Re: Subject: bool / vacuum full bug followup part 2
Next
From: Neil Conway
Date:
Subject: Re: Index usage vs large repetitions of key