X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 15F979FA2CB for ; Wed, 10 May 2006 16:22:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 52659-03 for ; Wed, 10 May 2006 16:22:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) by postgresql.org (Postfix) with ESMTP id 4FADB9FA293 for ; Wed, 10 May 2006 16:22:36 -0300 (ADT) Received: (qmail 1547 invoked from network); 10 May 2006 21:24:00 +0200 Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) by boutiquenumerique.com with SMTP; 10 May 2006 21:24:00 +0200 Date: Wed, 10 May 2006 21:23:59 +0200 To: pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Big IN() clauses etc : feature proposal References: <20060509105214.P90693@vesihiisi.cksoft.de> <20060509113337.M90693@vesihiisi.cksoft.de> <20060509103632.GD29652@svana.org> <1147190285.32304.43.camel@firebolt> <16680.1147201981@sss.pgh.pa.us> <20060510190011.GO99570@pervasive.com> From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <20060510190011.GO99570@pervasive.com> User-Agent: Opera M2/8.51 (Linux, build 1462) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/280 X-Sequence-Number: 83145 > Speaking of which, if a temp table is defined as ON COMMIT DROP or > DELETE ROWS, there shouldn't be any need to store xmin/xmax, only > cmin/cmax, correct? Yes, that's that type of table I was thinking about... You can't ROLLBACK a transaction on such a table. You can however rollback a savepoint and use "INSERT INTO tmp SELECT FROM tmp" which implies MVCC (I think ?) I was suggesting to be able to use FETCH (from a cursor) in the same way as SELECT, effectively using a named cursor (DECLARE...) as a simpler, faster version of a temporary table, but there is another (better ?) option : If rowcount estimates for functions are implemented, then a set-returning function can be written, which takes as argument a named cursor, and returns its rows. It would have accurate rowcount estimation (if the cursor is WITH SCROLL, which is the case here, rows are stored, so we know their number). Then you could do : DECLARE my_cursor ... AS (query that we only want to do once) SELECT ... FROM table1 JOIN fetch_cursor( my_cursor ) ON ... SELECT ... FROM table2 JOIN fetch_cursor( my_cursor ) ON ... SELECT ... FROM table3 JOIN fetch_cursor( my_cursor ) ON ... No need to redefine the FETCH keyword. An interesting functionalyty with minimal hassle.