Re: bind variables, soft vs hard parse

From: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: Marcus Engene <mengpg(at)engene(dot)se>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: bind variables, soft vs hard parse
Date: 2005-11-16 06:38:29
Message-ID: 36e682920511152238p32acbf81tc909085884fd73a8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In some cases, Oracle will also replace literals with bind variables so that
it can perform a sort-of-bind-value soft parse later.

On 11/15/05, Jim C. Nasby <jnasby(at)pervasive(dot)com> wrote:
>
> PostgreSQL combines both parses into one, so every new query is
> effectively a hard parse (unless it's prepared, then there is no parse
> or optimization at all).
>
> On Tue, Nov 15, 2005 at 07:33:46PM +0100, Marcus Engene wrote:
> > Hi list.
> >
> > I've mostly used Oracle in the past, but for a web-project I took the
> > opportunity to try Postgres.
> >
> > When a select is done in Oracle, it first checks if the select is cached
> > (ie parsed tree, optimizer choices & such). It does this by
> > [functionality equal to] a byte to byte compare with the other sql
> strings.
> >
> > select a from b where c = 1
> > select a from b where c = 2
> >
> > ...will thus force a hard parse on the second select. But if using bind
> > variables it wont as the string stored is something like
> >
> > select a from b where c = ?
> >
> > Which will be the same as the second call. There is quite a big
> > difference in performance using bind variables.
> >
> > Does Postgres work the same? Where can I go for more info?
> >
> > Oracle recently gave some money to Zend to make proper Oracle support
> > for PHP. In that interface they use bind variables. Apart from greater
> > speed, sqlinjection becomes history as well.
> >
> > Best regards,
> > Marcus
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: explain analyze is your friend
> >
>
> --
> Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
> Pervasive Software http://pervasive.com work: 512-231-6117
> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-11-16 06:59:17 Re: bind variables, soft vs hard parse
Previous Message Michael Glaesemann 2005-11-16 06:37:31 Re: Long-time 7.4 contrib failure Mac OS X 10.3.8