Re: Not same plan between static and prepared query

From: Ghislain ROUVIGNAC <ghr(at)sylob(dot)com>
To: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Not same plan between static and prepared query
Date: 2013-06-10 13:58:55
Message-ID: CAH12p1DN5DouG5sMhmkmZeKE3mp7AF0UHZ1p96sykry21jxPGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hello Amit,

Thank you for your help.

You are right, it work fine with PostgreSQL 9.2.

*Ghislain ROUVIGNAC*

2013/6/6 Amit Kapila <amit(dot)kapila(at)huawei(dot)com>

>
> 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)
>
> From PostgreSQL 9.2, it generates plan for prepared query during execution
> (Execute command) as well.
> So I think you will not face this problem in PostgreSQL 9.2 and above.
>
> With Regards,
> Amit Kapila.
>
>

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message bricklen 2013-06-10 14:36:03 Re: URGENT issue: pg-xlog growing on master!
Previous Message Dinesh Kumar 2013-06-10 11:47:38 Re: URGENT issue: pg-xlog growing on master!