From: Shigeru Hanada Date: Mon, 8 Nov 2010 01:58:55 +0000 (+0900) Subject: Fix postgresql_fdw to reuse contents of tuplestore through whole of X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=2c1d539ea3c7070931fe47393a98a210c6816a3e;p=users%2Fhanada%2Fpostgres.git Fix postgresql_fdw to reuse contents of tuplestore through whole of the query to avoid unnecessary re-execution of remote query. --- diff --git a/contrib/postgresql_fdw/postgresql_fdw.c b/contrib/postgresql_fdw/postgresql_fdw.c index abeb271126..288830430b 100644 --- a/contrib/postgresql_fdw/postgresql_fdw.c +++ b/contrib/postgresql_fdw/postgresql_fdw.c @@ -649,13 +649,9 @@ pgReOpen(ForeignScanState *scanstate) { pgFdwReply *reply = (pgFdwReply *) scanstate->reply; - /* Free Tuplestore to execute query again */ - /* TODO: reuse tupstore through the scan to avoid overhead */ + /* Rewind tuplestore to retrieve all tuples again */ if (reply->tupstore) - { - tuplestore_end(reply->tupstore); - reply->tupstore = NULL; - } + tuplestore_rescan(reply->tupstore); } /*