delayed planning of unnamed statements

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: delayed planning of unnamed statements
Date: 2004-05-24 15:03:29
Message-ID: 40B20EC1.9050702@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Per discussion on -hackers
(http://archives.postgresql.org/pgsql-hackers/2004-05/msg00990.php)
here is a first cut at delaying query planning for unnamed statements
until we have concrete parameters (i.e. at Bind).

This passes 'make check' (not particularly informative since that
doesn't exercise the extended query protocol path). It also passes the
JDBC driver's regression tests when using a modified driver that uses
the extended query protocol and parameterized queries.

Also attached is a python script that talks the V3 protocol directly and
does some simple tests of various bind/rebind cases with named and
unnamed statements (beware, that code is very ad-hoc!).

With these changes the JDBC driver gets performance similar to the
unparameterized case when using the unnamed statement:

> FE=> Parse(stmt=null,query="SELECT count(*) FROM test_big WHERE value = 2",oids={})
> FE=> Bind(stmt=null,portal=null)
> FE=> Describe(portal=null)
> FE=> Execute(portal=null,limit=0)
> FE=> Sync
> <=BE ParseComplete [null]
> <=BE BindComplete [null]
> <=BE RowDescription(1)
> <=BE DataRow
> <=BE CommandStatus(SELECT)
> <=BE ReadyForQuery(I)
> <<<<< END
> Elapsed: 54ms
> Result: 1

> FE=> Parse(stmt=S_1,query="SELECT count(*) FROM test_big WHERE value = $1",oids={23})
> FE=> Bind(stmt=S_1,portal=null,$1=<2>)
> FE=> Describe(portal=null)
> FE=> Execute(portal=null,limit=0)
> FE=> Sync
> <=BE ParseComplete [S_1]
> <=BE BindComplete [null]
> <=BE RowDescription(1)
> <=BE DataRow
> <=BE CommandStatus(SELECT)
> <=BE ReadyForQuery(I)
> <<<<< END
> Elapsed: 1484ms
> Result: 1

> FE=> Parse(stmt=null,query="SELECT count(*) FROM test_big WHERE value = $1",oids={23})
> FE=> Bind(stmt=null,portal=null,$1=<2>)
> FE=> Describe(portal=null)
> FE=> Execute(portal=null,limit=0)
> FE=> Sync
> <=BE ParseComplete [null]
> <=BE BindComplete [null]
> <=BE RowDescription(1)
> <=BE DataRow
> <=BE CommandStatus(SELECT)
> <=BE ReadyForQuery(I)
> <<<<< END
> Elapsed: 65ms
> Result: 1

-O

Attachment Content-Type Size
pgsql-server-delay-plan.txt text/plain 42.6 KB
v3test.py text/x-python 5.6 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Fabien COELHO 2004-05-24 15:52:12 pgxs: build infrastructure for extensions v1
Previous Message Gaetano Mendola 2004-05-24 14:46:10 Re: updated list rewrite