Re: Query not using index, please explain.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthew Hagerty <mhagerty(at)voyager(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Query not using index, please explain.
Date: 2001-03-08 20:19:43
Message-ID: 29777.984082783@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Matthew Hagerty <mhagerty(at)voyager(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Poole 2001-03-08 20:38:33 Re: Query not using index, please explain.
Previous Message Tom Lane 2001-03-08 20:04:22 Re: WAL does not recover gracefully from out-of-disk-sp ace