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

Re: [HACKERS] RQ: Prepared statements used by multiple connections

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Bojidar Mihajlov <bmihajlov(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-odbc(at)postgresql(dot)org
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
Date: 2005-01-25 09:37:43
Message-ID: 41F61367.5060807@familyhealth.com.au (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-odbc
> I need a mechanism to keep my queries in optimized 
> state so that multiple processes can use them.

You should use stored procedures then.

For instance, say you want to keep 'SELECT * FROM table WHERE id=x' 
prepared.  You would go:

CREATE OR REPLACE FUNCTION get_table_id(integer) RETURNS SETOF table AS 
'SELECT * FROM table WHERE id=$1' LANGUAGE SQL;

PostgreSQL will store a prepared version of that statement after its 
first use.

You use it like this:

SELECT * FROM get_table_id(3);

Chris

In response to

Responses

pgsql-hackers by date

Next:From: Neil ConwayDate: 2005-01-25 10:19:46
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
Previous:From: Michael PaesoldDate: 2005-01-25 09:30:01
Subject: Re: WAL: O_DIRECT and multipage-writer

pgsql-odbc by date

Next:From: Neil ConwayDate: 2005-01-25 10:19:46
Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections
Previous:From: Bojidar MihajlovDate: 2005-01-25 09:27:07
Subject: RQ: Prepared statements used by multiple connections

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