From: | Chris <dmagick(at)gmail(dot)com> |
---|---|
To: | David Kerr <dmk(at)mr-paradox(dot)net> |
Cc: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Optimizer + bind variables |
Date: | 2009-11-04 00:02:22 |
Message-ID: | 4AF0C48E.8090100@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
David Kerr wrote:
> On Wed, Nov 04, 2009 at 07:43:16AM +0800, Craig Ringer wrote:
> - David Kerr wrote:
> - > Does/is it possible for the PG optimizer come up with differnet plans when
> - > you're using bind variables vs when you send static values?
> -
> - Yes, if the bind variable form causes your DB access driver to use a
> - server-side prepared statement. Pg can't use its statistics to improve
> - its query planning if it doesn't have a value for a parameter when it's
> - building the query plan.
>
> hmm, that's a little unclear to me.
>
> let's assume that the application is using prepare:
>
> Assuming the database hasn't changed, would:
> PREPARE bla1 as SELECT * from users where username = '$1';
> explain execute bla1
>
> give the same output as
> explain select * from users where username = 'dave';
>
> ?
No.
This is explained in the notes here:
http://www.postgresql.org/docs/current/static/sql-prepare.html
--
Postgresql & php tutorials
http://www.designmagick.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2009-11-04 00:03:48 | Re: maintaining a reference to a fetched row |
Previous Message | David Kerr | 2009-11-03 23:52:46 | Re: Optimizer + bind variables |