pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Scott Carey <scott@richrelevance.com>
Cc: bricklen <bricklen@gmail.com>
Cc: Scott Marlowe <scott.marlowe@gmail.com>
Cc: Merlin Moncure <mmoncure@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Poor plan choice in prepared statement
Date: Wed, 31 Dec 2008 13:01:18 -0300
Message-ID: <20081231160118.GE3809@alvh.no-ip.org> (raw)
In-Reply-To: <2796.1230678149@sss.pgh.pa.us>
References: <33b743250812301059u31ce82faw3d72a38280b37402@mail.gmail.com>
	<b42b73150812301142w4483978ahfb819b0313150dbb@mail.gmail.com>
	<BDFBB77C9E07BE4A984DAAE981D19F961ACD5F388E@EXVMBX018-1.exch018.msoutlookonline.net>
	<2796.1230678149@sss.pgh.pa.us>

Tom Lane escribió:
> Scott Carey <scott@richrelevance.com> writes:
> > I have also had a case where one query would take a  couple hundred
> > ms to parse, but was fairly fast to plan and execute (1/3 the parse
> > cost) -- yet another case where a prepared statement that re-plans
> > each execution would be helpful.  At least you can prevent SQL
> > injection and cut the parse cost.  Its not all about the cost of
> > planning the query.
> 
> The point of a prepared statement IMHO is to do the planning only once.
> There's necessarily a tradeoff between that and having a plan that's
> perfectly adapted to specific parameter values.

I think it has been shown enough times that the performance drop caused
by a worse plan can be orders of magnitudes worse than what's gained by
producing the plan only once.  It does not seem a bad idea to provide a
way to carry out only the parse phase, and postpone planning until the
parameters have been received.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.



view thread (20+ messages)  latest in thread

Message-ID: <20081231160118.GE3809@alvh.no-ip.org>
Permalink:  ../20081231160118.GE3809@alvh.no-ip.org/
Also on:    postgresql.org/message-id/20081231160118.GE3809@alvh.no-ip.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: alvherre@commandprompt.com, tgl@sss.pgh.pa.us, scott@richrelevance.com, bricklen@gmail.com, scott.marlowe@gmail.com, mmoncure@gmail.com
  Subject: Re: Poor plan choice in prepared statement
  In-Reply-To: <20081231160118.GE3809@alvh.no-ip.org>
  References: <33b743250812301059u31ce82faw3d72a38280b37402@mail.gmail.com> <b42b73150812301142w4483978ahfb819b0313150dbb@mail.gmail.com> <BDFBB77C9E07BE4A984DAAE981D19F961ACD5F388E@EXVMBX018-1.exch018.msoutlookonline.net> <2796.1230678149@sss.pgh.pa.us> <20081231160118.GE3809@alvh.no-ip.org>

* 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