Unix Technical Forum

JDBC addBatch more efficient?

This is a discussion on JDBC addBatch more efficient? within the Pgsql General forums, part of the PostgreSQL category; --> Just checking if the JDBC library's batch processing code is more efficient with respect to the postgresql back end ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 08:09 PM
David Wall
 
Posts: n/a
Default JDBC addBatch more efficient?

Just checking if the JDBC library's batch processing code is more
efficient with respect to the postgresql back end or not. Does it
really batch the requests and submit them once over the link, or does it
just send them to the database to be processed one at a time?

Thanks,
David

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-21-2008, 08:40 AM
Kris Jurka
 
Posts: n/a
Default Re: JDBC addBatch more efficient?



On Sun, 20 Apr 2008, David Wall wrote:

> Just checking if the JDBC library's batch processing code is more efficient
> with respect to the postgresql back end or not. Does it really batch the
> requests and submit them once over the link, or does it just send them to the
> database to be processed one at a time?
>


The JDBC driver's batch processing is more efficient than regular
execution because it requires fewer network roundtrips so there's less
waiting. The JDBC batch is broken into an internal batch size of 256
statement and all of these are sent over to the server at once.

Kris Jurka

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-24-2008, 07:10 PM
David Wall
 
Posts: n/a
Default Re: JDBC addBatch more efficient?


> The JDBC driver's batch processing is more efficient than regular
> execution because it requires fewer network roundtrips so there's less
> waiting. The JDBC batch is broken into an internal batch size of 256
> statement and all of these are sent over to the server at once.


That's great, Kris. I believe our code only does 100 updates/deletes
before committing the transaction anyway, so this should work well for us.

Thanks,
David

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-24-2008, 07:10 PM
Ivano Luberti
 
Posts: n/a
Default Re: JDBC addBatch more efficient?

Does this means that the two features are independent one from each other ?
In other words, can we say that JDBC batch will limit information
exchange between client and server while Postgres prepared statements
will optimize their execution ?

Kris Jurka ha scritto:
>
>
> On Sun, 20 Apr 2008, David Wall wrote:
>
>> Just checking if the JDBC library's batch processing code is more
>> efficient with respect to the postgresql back end or not. Does it
>> really batch the requests and submit them once over the link, or does
>> it just send them to the database to be processed one at a time?
>>

>
> The JDBC driver's batch processing is more efficient than regular
> execution because it requires fewer network roundtrips so there's less
> waiting. The JDBC batch is broken into an internal batch size of 256
> statement and all of these are sent over to the server at once.
>
> Kris Jurka
>


--
==================================================
Archimede Informatica NEWS!
==================================================

Realizzato il Sistema Integrato per la biglietteria della Torre di Pisa:
prenotazione, vendita, pre-vendita ed emissione dei biglietti di ingresso
alla Torre sia online che presso le biglietterie dislocate sulla piazza:

_http://www.opapisa.it/boxoffice

_Partner del Progetto Ci-Tel "Front office Telematico per il cittadino"
Ente Coordinatore Comune di Pisa

_http://www.comune.pisa.it/doc/e-government.htm


_================================================= =
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
e-mail: archimede@archicoop.it
web: _http://www.archicoop.it


_ <http://www.archicoop.it/>__ <http://www.archicoop.it/>

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-24-2008, 07:10 PM
David Wall
 
Posts: n/a
Default Re: JDBC addBatch more efficient?


> Does this means that the two features are independent one from each
> other ?
> In other words, can we say that JDBC batch will limit information
> exchange between client and server while Postgres prepared statements
> will optimize their execution ?

I've not used it yet, but my impression is that you can use
PreparedStatements (in a loop typically), often surrounded by jdbc
transaction commit so each statement doesn't run in its own
transactions, do an addBatch and then submit that so all of the
statements are executed by the server as a group. So in this case, yes,
they should be independent of each other.

David

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com