Re: Avoiding bad prepared-statement plans.
Bruce Momjian <bruce@momjian.us>
From: Bruce Momjian <bruce@momjian.us>
To: Greg Stark <gsstark@mit.edu>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Robert Haas <robertmhaas@gmail.com>, Bart Samwel <bart@samwel.tk>, Jeroen Vermeulen <jtv@xs4all.nl>, pgsql-hackers@postgresql.org
Date: 2010-02-16T20:17:32Z
Lists: pgsql-hackers
Attachments
- /rtmp/diff (text/x-diff) patch
Greg Stark wrote: > On Mon, Feb 15, 2010 at 7:11 PM, Bruce Momjian <bruce@momjian.us> wrote: > > 1. Why do we only do bind-level planning for anonymous wire-level queries? > > > > 2. I realize we did anonymous-only because that was the only way we had > > in the protocol to _signal_ bind-time planning, but didn't we think of > > this when we were implementing the wire-level protocol? > > Is there any other difference between anonymous and non-anonymous > queries? If this is the only major difference do we need to separate > them? Is there any particular reason a driver would need two prepared > queries if they're both just going to be planned at execution time? Well, anonymous prepared queries are replanned for _every_ bind, so I don't see a huge value in allowing multiple unnamed queries, except you have to re-send the old query to prepare if you need to reuse it. In fact, this behavior was not totally clear so I updated the documentation a little with the attached patch. > Incidentally, can you have two active anonymous portals at the same time? No, the first one is deleted when the second is created, i.e., our docs have: An unnamed prepared statement lasts only until the next Parse statement specifying the unnamed statement as destination is issued. (Note that a simple Query message also destroys the unnamed statement.) -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +