Re: Query not using index, please explain.
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matthew Hagerty <mhagerty@voyager.net>
Cc: pgsql-hackers@postgresql.org
Date: 2001-03-08T20:19:43Z
Lists: pgsql-hackers
Matthew Hagerty <mhagerty@voyager.net> writes: > The query where the time_stamp < '03-01-2000' does not return any rows, the > 04-01-2000 date does return rows. When I disable seqscan the query is > almost instant, but with it on, it takes about 3 or 4 minutes. Why can't > the query planner use the index in the later case? It *can* (and did, in two of the three examples you gave). It just doesn't think the indexscan is faster --- note the cost estimates. Evidently the cost estimates are way off, probably because the estimated number of selected rows is way off. Have you done a VACUUM ANALYZE lately? Not that that will help if the distribution of timestamps is highly irregular :-(. See the many past discussions of these issues. regards, tom lane