From: Brian G. Huber <brianghuber@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Cursor returned from procedure ignores setFetchSize() on CallableStatement
Date: Tue, 8 Jun 2004 00:40:14 -0500
Message-ID: <001a01c44d1b$131f7160$6400a8c0@bghthinkpad> (raw)
Hello all -
I need to return large result sets and therefore need a cursor with a small
fetch size (to avoid caching the entire query at once). However, it appears
that when a cursor is returned from a callable statement setFetchSize is
ignored.
I set up a query that crashes with outofMemoryError if entire query is
cached. I am able to sucsessfully use a Statement and setFetchSize() to
avoid the crash. However, when I put the code in a procedure, the
outofMEmoryError throws before I even try to access the result set,
indicating that the entire query is caching. This is true with or without
calling setFetchSize on the ResultSet in addition to the CallableStatement.
Is this a bug or am I doing something wrong? Any comments greatly
appreciated. Thanks
Client
Code------------------------------------------------------------------------
-----------
cn.setAutoCommit(false);
CallableStatement proc = cn.prepareCall("{ ? = call reffunc2('cursor1') }");
proc.setFetchSize(100);
proc.registerOutParameter(1, Types.OTHER);
proc.execute();
rds = (ResultSet) proc.getObject(1);
rds.setFetchSize(100);
while (rds.next()){
...
}
Function--------------------------------------------------------------------
---------------------------------------------
CREATE OR REPLACE FUNCTION public.reffunc2(refcursor) RETURNS refcursor AS '
BEGIN
OPEN $1 FOR SELECT ...<Large Query>...;
RETURN $1;
END;
' LANGUAGE 'plpgsql' VOLATILE;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: brianghuber@yahoo.com
Subject: Re: Cursor returned from procedure ignores setFetchSize() on CallableStatement
In-Reply-To: <001a01c44d1b$131f7160$6400a8c0@bghthinkpad>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox