Index usage vs large repetitions of key

From: Francisco Reyes <lists(at)natserv(dot)com>
To: pgsql General List <pgsql-general(at)postgresql(dot)org>
Subject: Index usage vs large repetitions of key
Date: 2002-05-04 20:25:47
Message-ID: 20020504160120.B66845-100000@zoraida.natserv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-05-04 20:35:34 Re: Index usage vs large repetitions of key
Previous Message Jeffrey Baker 2002-05-04 19:52:17 Re: Subject: bool / vacuum full bug followup part 2