Re: RQ: Prepared statements used by multiple connections

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: RQ: Prepared statements used by multiple connections
Дата
Msg-id 41F61367.5060807@familyhealth.com.au
обсуждение исходный текст
Ответ на RQ: Prepared statements used by multiple connections  (Bojidar Mihajlov <bmihajlov@yahoo.com>)
Ответы Re: RQ: Prepared statements used by multiple connections  (Neil Conway <neilc@samurai.com>)
Список pgsql-hackers
> 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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bojidar Mihajlov
Дата:
Сообщение: RQ: Prepared statements used by multiple connections
Следующее
От: Neil Conway
Дата:
Сообщение: Re: RQ: Prepared statements used by multiple connections