Re: IN list processing performance (yet again) - Mailing list pgsql-performance

From Tom Lane
Subject Re: IN list processing performance (yet again)
Date
Msg-id 13453.1054172773@sss.pgh.pa.us
Whole thread Raw
In response to Re: IN list processing performance (yet again)  (Dave Tenny <tenny@attbi.com>)
List pgsql-performance
Dave Tenny <tenny@attbi.com> writes:
> </blockquote>
> There is one very interesting thing in my test case though.  It
> certainly <i>seemed</i> as if the<br>
> parameterized statements were successfully using the index of the
> freshly-created-but-unanalyzed table,<br>
> or else the times on those queries would have been terrible too.  It
> was only the IN list form<br>
> of query that wasn't making correct use of the index.  How can the
> planner recognize uniqueness for<br>
> one case but not the other?

The question is whether a seqscan will be faster than an indexscan; at
some point there's less I/O involved to just scan the table once.  If
the planner doesn't know the index is unique then it's going to estimate
a higher cost for the indexscan (due to more rows fetched) and there is
some number of rows at which it will flip over to a seqscan.  The same
will happen even if it *does* know the index is unique, it's just that
it will take more IN elements to make it happen.  This is reasonable
behavior IMHO, although whether the flip-over point is anywhere near
the actual breakeven point on your hardware is anyone's guess.  The cost
estimates are often far enough off that it's not very close.

            regards, tom lane

pgsql-performance by date:

Previous
From: Dave Tenny
Date:
Subject: Re: IN list processing performance (yet again)
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: IN list processing performance (yet again)