pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Meinel <john@johnmeinel.com>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32@postgresql.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Poor Performance for large queries
Date: Wed, 29 Sep 2004 09:56:27 -0500
Message-ID: <415ACD1B.1020003@johnmeinel.com> (raw)
In-Reply-To: <415A74EB.9040308@archonet.com>
References: <4155C955.40808@dunslane.net>
	<415A288F.2030002@johnmeinel.com>
	<22682.1096434647@sss.pgh.pa.us>
	<415A575F.2060802@johnmeinel.com>
	<415A74EB.9040308@archonet.com>

Richard Huxton wrote:
> John Meinel wrote:
> 
>>
>> So notice that when doing the actual select it is able to do the index 
>> query. But for some reason with a prepared statement, it is not able 
>> to do it.
>>
>> Any ideas?
> 
> 
> In the index-using example, PG knows the value you are comparing to. So, 
> it can make a better estimate of how many rows will be returned. With 
> the prepared/compiled version it has to come up with a plan that makes 
> sense for any value.
> 
> If you look back at the explain output you'll see PG is guessing 181,923 
> rows will match with the prepared query but only 1 for the second query. 
> If in fact you returned that many rows, you wouldn't want to use the 
> index - it would mean fetching values twice.
> 
> The only work-around if you are using plpgsql functions is to use 
> EXECUTE to make sure your queries are planned for each value provided.
> 
I suppose that make sense. If the number was small (< 100) then there 
probably would be a lot of responses. Because the tproject table is all 
small integers.

But for a large number, it probably doesn't exist on that table at all.

Thanks for the heads up.

John
=:->

Attachments:

  signature.asc (application/pgp-signature, 252B) download

view thread (3+ messages)  latest in thread

Message-ID: <415ACD1B.1020003@johnmeinel.com>
Permalink:  ../415ACD1B.1020003@johnmeinel.com/
Also on:    postgresql.org/message-id/415ACD1B.1020003@johnmeinel.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: john@johnmeinel.com, dev@archonet.com, pgsql-hackers-win32@postgresql.org
  Subject: Re: [PERFORM] Poor Performance for large queries
  In-Reply-To: <415ACD1B.1020003@johnmeinel.com>

* 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