Re: sql query not using indexes - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: sql query not using indexes
Date
Msg-id Pine.BSF.4.10.10009221005340.66920-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: sql query not using indexes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
On Fri, 22 Sep 2000, Tom Lane wrote:

> indexscans; the current code may have overcorrected a shade, but I think
> it's closer to reality than 6.5 was.
> 
> As Hiroshi already commented, the difference in results suggests that
> the desired data is very nonuniformly scattered in the table.  7.0
> computes cost estimates on the assumption that the target data is
> uniformly scattered.  For a sufficiently nonselective WHERE condition
> (ie, one that the planner thinks will match a large fraction of the
> table's rows) it looks better to do a seqscan and pick up the matching
> rows than to follow the index pointers.  Adding a LIMIT doesn't change
> this equation.
>
> I like Hiroshi's recommendation: add an ORDER BY to help favor the
> indexscan.

Yeah, I didn't notice the lack of the order by when I responded.  I
forget that order by isn't required to use limit since it's fairly
ugly to not use one ("What, you wanted to get a implementation defined
effectively random 10 rows?")




pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: sql query not using indexes
Next
From: Jie Liang
Date:
Subject: Re: how to store a query, that results in a table