Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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: v3test.py
Description: text/x-python (5.6 KB)
Attachment: pgsql-server-delay-plan.txt
Description: text/plain (42.6 KB)

Responses

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group