Unix Technical Forum

PREPARE and stuff

This is a discussion on PREPARE and stuff within the Pgsql Performance forums, part of the PostgreSQL category; --> Suppose a web application with persistent database connections. I have some queries which take longer to plan than to ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 10:06 AM
PFC
 
Posts: n/a
Default PREPARE and stuff


Suppose a web application with persistent database connections.
I have some queries which take longer to plan than to execute !

I with there was a way to issue a PREPARE (like "PERSISTENT PREPARE").
Now all Postgres connections would know that prepared statement foo( $1,
$2, $3 ) corresponds to some SQL query, but it wouldn't plan it yet. Just
like a SQL function.
When invoking EXECUTE foo( 1,2,3 ) on any given connection the statement
would get prepared and planned. Then on subsequent invocations I'd just
get the previously prepared plan.

Is this planned ?

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 10:07 AM
Heikki Linnakangas
 
Posts: n/a
Default Re: PREPARE and stuff

PFC wrote:
>
> Suppose a web application with persistent database connections.
> I have some queries which take longer to plan than to execute !
>
> I with there was a way to issue a PREPARE (like "PERSISTENT PREPARE").
> Now all Postgres connections would know that prepared statement foo(
> $1, $2, $3 ) corresponds to some SQL query, but it wouldn't plan it yet.
> Just like a SQL function.
> When invoking EXECUTE foo( 1,2,3 ) on any given connection the
> statement would get prepared and planned. Then on subsequent invocations
> I'd just get the previously prepared plan.


How would that be different from the current PREPARE/EXECUTE? Do you
mean you could PREPARE in one connection, and EXECUTE in another? If
you're using persistent connections, it wouldn't be any faster than
doing a PREPARE once in each connection.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 10:07 AM
Gregory Stark
 
Posts: n/a
Default Re: PREPARE and stuff

"PFC" <lists@peufeu.com> writes:

> Suppose a web application with persistent database connections.
> I have some queries which take longer to plan than to execute !


There have periodically been discussions about a shared plan cache but
generally the feeling is that it would do more harm than good and there are no
plans to implement anything like that.

For a web application though you would expect to be executing the same queries
over and over again since you would be executing the same pages over and over
again. So just a regular prepared query ought to good for your needs.

You do not want to be reconnecting to the database for each page fetch.
Replanning queries is the least of the problems with that approach.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:56 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com