From: Craig Ringer <craig@postnewspapers.com.au>
To: Maciek Sakrejda <msakrejda@truviso.com>
Cc: Boris <boris.partensky@gmail.com>
Cc: PG-JDBC Mailing List <pgsql-jdbc@postgresql.org>
Subject: Re: Upgrading JDBC driver from 7.3 to 8.4 affected execution plans
Date: Mon, 04 Oct 2010 12:00:10 +0800
Message-ID: <4CA9514A.4090404@postnewspapers.com.au> (raw)
In-Reply-To: <AANLkTi=0U0q34COq5kUgXTVyW71OduH6O3JepTsgnyu0@mail.gmail.com>
References: <9c7afd41-61f0-4acb-bc14-bb10aeaf395f@d17g2000yqm.googlegroups.com>
<4CA91F81.4050505@opencloud.com>
<AANLkTi=0U0q34COq5kUgXTVyW71OduH6O3JepTsgnyu0@mail.gmail.com>
On 04/10/10 11:35, Maciek Sakrejda wrote:
> Could this be related to how planning works with respect to
> parameterized queries [1]? If memory serves, a prepared statement is
> typically planned once and that plan is used each time the statement
> is executed. There can be some issues around this because when you
> have a query like "SELECT * FROM foo WHERE bar > ?", the planner has
> no idea of the selectivity of that predicate if it has to plan the
> query before it knows what the parameters will be. E.g., if it picks
> an index scan and then a query is submitted where ? is 10, if 95% of
> bars are greater than 10, the executor will waste a lot of time
> mucking around with the index where it should just be doing a seq
> scan.
IMO Pg would be well served by supporting something like "EXECUTE WITH
REPLAN" or a PREPARE that doesn't cache the plan, only storing the
parsed statement and handling parameter substitution.
This is in the TODO as "Allow finer control over the caching of prepared
query plans" http://wiki.postgresql.org/wiki/Todo . Perhaps this is
something a few commercial users of Pg might consider getting together
and sponsoring work on?
--
Craig Ringer
Tech-related writing: http://soapyfrogs.blogspot.com/
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: craig@postnewspapers.com.au, msakrejda@truviso.com, boris.partensky@gmail.com
Subject: Re: Upgrading JDBC driver from 7.3 to 8.4 affected execution plans
In-Reply-To: <4CA9514A.4090404@postnewspapers.com.au>
References: <9c7afd41-61f0-4acb-bc14-bb10aeaf395f@d17g2000yqm.googlegroups.com> <4CA91F81.4050505@opencloud.com> <AANLkTi=0U0q34COq5kUgXTVyW71OduH6O3JepTsgnyu0@mail.gmail.com> <4CA9514A.4090404@postnewspapers.com.au>
* 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