X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 448C53A4E20; Tue, 25 Jan 2005 09:38:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32522-05; Tue, 25 Jan 2005 09:38:37 +0000 (GMT) Received: from server.cityscape3d.com (unknown [217.206.144.18]) by svr1.postgresql.org (Postfix) with ESMTP id 955413A46C8; Tue, 25 Jan 2005 09:38:35 +0000 (GMT) Received: from [192.168.1.117] ([192.168.1.117]) by server.cityscape3d.com (8.12.11/8.11.6) with ESMTP id j0P9HmqX089856; Tue, 25 Jan 2005 09:17:48 GMT (envelope-from chriskl@familyhealth.com.au) Received: from 127.0.0.1 (AVG SMTP 7.0.302 [265.7.3]); Tue, 25 Jan 2005 09:37:43 +0000 Message-ID: <41F61367.5060807@familyhealth.com.au> Date: Tue, 25 Jan 2005 09:37:43 +0000 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bojidar Mihajlov Cc: pgsql-hackers@postgresql.org, pgsql-odbc@postgresql.org Subject: Re: [HACKERS] RQ: Prepared statements used by multiple connections References: <20050125092707.32541.qmail@web50502.mail.yahoo.com> In-Reply-To: <20050125092707.32541.qmail@web50502.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.122 tagged_above=0 required=5 tests=AWL, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200501/74 X-Sequence-Number: 4869 > 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