pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
setFetchSize question
4+ messages / 4 participants
[nested] [flat]

* setFetchSize question
@ 2005-02-25 16:12 Alan Stange <stange@rentec.com>
  2005-02-25 16:21 ` Re: setFetchSize question Dave Smith <dave.smith@candata.com>
  2005-02-25 19:05 ` Re: setFetchSize question Kris Jurka <books@ejurka.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Alan Stange @ 2005-02-25 16:12 UTC (permalink / raw)
  To: pgsql-jdbc

Hello all,

I just noticed something and I thought I'd ask:

When reading large chunks of data in the 7.4 JDBC client I would code 
something like this:

conn.setAutoCommit(false);
st.setFetchDirection(ResultSet.FETCH_FORWARD);
st.setFetchSize(1000);
st.executeQuery("select * from foo");

which would result in queries to the postgresql server like this:

DECLARE JDBC_CURS_588 CURSOR FOR select * from foo; fetch forward 1000 
from JDBC_CURS_588;

with subsequent fetch forward queries being executed as the full result 
set is pulled in.

In the 8.0 driver I don't see this happening.   I see only the "select * 
from foo" query in the postgresql server log.

Is the query result still being sent in batch chunks of 1000 rows, but 
using a different mechanism?

Thanks!

-- Alan





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: setFetchSize question
  2005-02-25 16:12 setFetchSize question Alan Stange <stange@rentec.com>
@ 2005-02-25 16:21 ` Dave Smith <dave.smith@candata.com>
  2005-02-25 20:42   ` Re: setFetchSize question Oliver Jowett <oliver@opencloud.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Dave Smith @ 2005-02-25 16:21 UTC (permalink / raw)
  To: Alan Stange <stange@rentec.com>; +Cc: pgsql-jdbc

Funny, I'm trying to do the same thing. I think the problem is that V3
protocol (bind/execute) , Postgresql does not log the portal command
just the SQL statement. I'm busy trying to find the link in the archives
to this problem ..

On Fri, 2005-02-25 at 11:12, Alan Stange wrote:
> Hello all,
> 
> I just noticed something and I thought I'd ask:
> 
> When reading large chunks of data in the 7.4 JDBC client I would code 
> something like this:
> 
> conn.setAutoCommit(false);
> st.setFetchDirection(ResultSet.FETCH_FORWARD);
> st.setFetchSize(1000);
> st.executeQuery("select * from foo");
> 
> which would result in queries to the postgresql server like this:
> 
> DECLARE JDBC_CURS_588 CURSOR FOR select * from foo; fetch forward 1000 
> from JDBC_CURS_588;
> 
> with subsequent fetch forward queries being executed as the full result 
> set is pulled in.
> 
> In the 8.0 driver I don't see this happening.   I see only the "select * 
> from foo" query in the postgresql server log.
> 
> Is the query result still being sent in batch chunks of 1000 rows, but 
> using a different mechanism?
> 
> Thanks!
> 
> -- Alan
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org
-- 
Dave Smith
CANdata Systems Ltd
416-493-9020




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: setFetchSize question
  2005-02-25 16:12 setFetchSize question Alan Stange <stange@rentec.com>
  2005-02-25 16:21 ` Re: setFetchSize question Dave Smith <dave.smith@candata.com>
@ 2005-02-25 20:42   ` Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2005-02-25 20:42 UTC (permalink / raw)
  To: Dave Smith <dave.smith@candata.com>; +Cc: Alan Stange <stange@rentec.com>; pgsql-jdbc

Dave Smith wrote:
> Funny, I'm trying to do the same thing. I think the problem is that V3
> protocol (bind/execute) , Postgresql does not log the portal command
> just the SQL statement. I'm busy trying to find the link in the archives
> to this problem ..

Yeah, V3 introduces some logging issues. Only the initial Parse is 
logged, but a) just because we ran a Parse doesn't actually mean the 
query has been run and b) a single Parse might be followed by multiple 
Bind/Execute pairs that actually run the query multiple times (and those 
Bind/Executes might happen hours after the Parse!). So statement logging 
no longer gives you a good idea of what queries are being executed.

Fixing this on the server side is on my todo list but not too high at 
the moment.

The portal-execution thing is similar -- for a single query execution, 
there might be multiple Executes sent for the same portal (with a 
max-rows limit in place). That's less of a logging issue since it's 
logically the same query running across all of those Executes, we're 
just asking for the results one bit at a time.

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: setFetchSize question
  2005-02-25 16:12 setFetchSize question Alan Stange <stange@rentec.com>
@ 2005-02-25 19:05 ` Kris Jurka <books@ejurka.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Kris Jurka @ 2005-02-25 19:05 UTC (permalink / raw)
  To: Alan Stange <stange@rentec.com>; +Cc: pgsql-jdbc; dave.smith@candata.com



On Fri, 25 Feb 2005, Alan Stange wrote:

> conn.setAutoCommit(false);
> st.setFetchDirection(ResultSet.FETCH_FORWARD);
> st.setFetchSize(1000);
> st.executeQuery("select * from foo");
> 
> which would result in queries to the postgresql server like this:
> 
> DECLARE JDBC_CURS_588 CURSOR FOR select * from foo; fetch forward 1000 
> from JDBC_CURS_588;
> 
> In the 8.0 driver I don't see this happening.   I see only the "select * 
> from foo" query in the postgresql server log.
> 
> Is the query result still being sent in batch chunks of 1000 rows, but 
> using a different mechanism?
> 

Yes, it is still being sent in batches, but it uses the V3 protocol 
ability to partially execute portals.  An Execute message takes a 
maximum number of rows to return parameter, which is the fetch size.  
Debugging what the driver is actually doing can be done by adding 
?loglevel=2 to the URL which will log all the frontend/backend messages 
sent/received.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-02-25 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-25 16:12 setFetchSize question Alan Stange <stange@rentec.com>
2005-02-25 16:21 ` Dave Smith <dave.smith@candata.com>
2005-02-25 20:42   ` Oliver Jowett <oliver@opencloud.com>
2005-02-25 19:05 ` Kris Jurka <books@ejurka.com>

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