pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Tenny <tenny@attbi.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: IN list processing performance (yet again)
Date: Wed, 28 May 2003 21:46:13 -0400
Message-ID: <13453.1054172773@sss.pgh.pa.us> (raw)
In-Reply-To: <3ED5603C.2020800@attbi.com>
References: <3ED4B0E5.3050703@attbi.com>
	<9207.1054165441@sss.pgh.pa.us>
	<3ED5603C.2020800@attbi.com>

Dave Tenny <tenny@attbi.com> writes:
> </blockquote>
> There is one very interesting thing in my test case though.&nbsp; 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.&nbsp; It
> was only the IN list form<br>
> of query that wasn't making correct use of the index.&nbsp; 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



view thread (23+ messages)  latest in thread

Message-ID: <13453.1054172773@sss.pgh.pa.us>
Permalink:  ../13453.1054172773@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13453.1054172773@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tenny@attbi.com
  Subject: Re: IN list processing performance (yet again)
  In-Reply-To: <13453.1054172773@sss.pgh.pa.us>
  References: <3ED4B0E5.3050703@attbi.com> <9207.1054165441@sss.pgh.pa.us> <3ED5603C.2020800@attbi.com> <13453.1054172773@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox