pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gregory Stark <stark@enterprisedb.com>
Cc: pgsql-hackers@postgreSQL.org
Cc: pgsql-jdbc@postgreSQL.org
Subject: Re: Plan invalidation vs. unnamed prepared statements
Date: Tue, 06 Mar 2007 13:14:42 -0500
Message-ID: <6706.1173204882@sss.pgh.pa.us> (raw)
In-Reply-To: <87fy8i9rkv.fsf@stark.xeocode.com>
References: <6080.1173201777@sss.pgh.pa.us>
	<87fy8i9rkv.fsf@stark.xeocode.com>

Gregory Stark <stark@enterprisedb.com> writes:
> Can we forcibly discard it if *any* messages are received that might
> invalidate a plan? So basically it would work fine unless anyone in the system
> does any DDL at all? I guess that has the downside of introducing random
> unpredictable failures.

Ugh :-(

> Or stash the query string and replan it (possibly in the query cache this
> time) if someone executes it a second time?

I think that's either my plan A or C.

The main problem with uncontrolled replanning is that there's no way to
detect a change in the query properties.  For example suppose the query
is "SELECT * FROM foo" and we've already told the client (via Describe
Statement) that that returns two integer columns.  If an inval now
arrives because of "ALTER TABLE foo ADD COLUMN" (or perhaps worse, ALTER
COLUMN TYPE), we've got a problem.  If we just blindly replan then we'll
return tuples that do not match the previously given row description,
which will certainly break most clients.

The plan caching module has enough infrastructure to detect and complain
about these sorts of situations, and it also knows how to manage lock
acquisition so that once we've decided a plan is still good, the tables
won't change underneath us while we use the plan.  I don't see any way
to make comparable guarantees without the overhead that goes with the
cache manager.

			regards, tom lane



view thread (8+ messages)  latest in thread

Message-ID: <6706.1173204882@sss.pgh.pa.us>
Permalink:  ../6706.1173204882@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6706.1173204882@sss.pgh.pa.us

 · 

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-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, stark@enterprisedb.com, pgsql-hackers@postgreSQL.org
  Subject: Re: Plan invalidation vs. unnamed prepared statements
  In-Reply-To: <6706.1173204882@sss.pgh.pa.us>
  References: <6080.1173201777@sss.pgh.pa.us> <87fy8i9rkv.fsf@stark.xeocode.com> <6706.1173204882@sss.pgh.pa.us>

* 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