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?