Re: [PERFORM] Big IN() clauses etc : feature proposal - Mailing list pgsql-hackers

From PFC
Subject Re: [PERFORM] Big IN() clauses etc : feature proposal
Date
Msg-id op.s9cn5908cigqcu@apollo13
Whole thread Raw
In response to Re: [PERFORM] Big IN() clauses etc : feature proposal  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-hackers
> 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
rollbacka 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.



pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: [PERFORM] Big IN() clauses etc : feature proposal
Next
From: "Jim C. Nasby"
Date:
Subject: Re: [PERFORM] Big IN() clauses etc : feature proposal