pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <amit.kapila@huawei.com>
To: 'Ghislain ROUVIGNAC' <ghr@sylob.com>
To: pgsql-performance@postgresql.org
Subject: Re: Not same plan between static and prepared query
Date: Thu, 6 Jun 2013 16:10:58 +0530
Message-ID: <007201ce62a2$56c35930$044a0b90$@kapila@huawei.com> (raw)
In-Reply-To: <CAH12p1AvzORBOBhpCOYc7NHpRrYdpLei3SX4oiCn3pw+LgT4xQ@mail.gmail.com>
References: <CAH12p1AvzORBOBhpCOYc7NHpRrYdpLei3SX4oiCn3pw+LgT4xQ@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>


On Thursday, June 06, 2013 1:56 PM Ghislain ROUVIGNAC wrote:
> Hello,


> We have a strange issue related to a prepared statement.


> We have two equals queries where the sole difference is in the limit.
> - The first is hard coded with limit 500.
> - The second is prepared with limit $1 ($1 is bound to 500).


> PostgreSQL give us two different plans with a huge execution time for the
prepared query:

It can generate different plan for prepared query, because optimizer uses
default selectivity in case of bound parameters (in your case limit $1).


> We met the same behaviour with both :
> - PostgreSQL 8.4.8 on Windows 2008 (Prod)
> - PostgreSQL 8.4.8 and 8.4.17 on Windows 7 (Dev)



view thread (6+ messages)  latest in thread

Message-ID: <007201ce62a2$56c35930$044a0b90$@kapila@huawei.com>
Permalink:  ../007201ce62a2$56c35930$044a0b90$@kapila@huawei.com/
Also on:    postgresql.org/message-id/007201ce62a2$56c35930$044a0b90$@kapila@huawei.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: amit.kapila@huawei.com, ghr@sylob.com
  Subject: Re: Not same plan between static and prepared query
  In-Reply-To: <007201ce62a2$56c35930$044a0b90$@kapila@huawei.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