From: Kris Jurka <books@ejurka.com>
To: Haifeng Liu <liuhaifeng@live.com>
Cc: dmp <danap@ttc-cmc.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Date: Fri, 14 Dec 2012 11:51:14 -0500 (EST)
Message-ID: <alpine.BSO.2.00.1212141147030.30031@leary.csoft.net> (raw)
In-Reply-To: <BLU0-SMTP1534C0E74C7BF8FD348BE51B94D0@phx.gbl>
References: <BLU0-SMTP1143B3C57133A122263A47AB94E0@phx.gbl>
<BLU0-SMTP23378AE609963CCB543ED38B94D0@phx.gbl>
<50CB4C40.7000104@ttc-cmc.net>
<BLU0-SMTP1534C0E74C7BF8FD348BE51B94D0@phx.gbl>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
On Sat, 15 Dec 2012, Haifeng Liu wrote:
> I did a simple test and found that if one of the batch failed, the other
> update may be execute partially. when I test with 10 updates a batch,
> none of them are updated, when I test with 1000 updates a batch, about
> 700+ of them are executed, but the failed update should be the last one,
> which means 999 executed updates is more reasonable than 700+. But
> really weird thing is the getUpdateCounts method returns the reasonable
> information.
>
> I don't know what happened inside this driver. Currently I have to
> setAutoCommit to false and use commit/rollback to achieve my goal.
>
Internally the driver splits each batch into sub-batches of 250 to send to
the server to reduce the possibility of deadlocking the network
connection. When auto-commit is enabled in the driver, the auto-commit
setting affects the whole sub-batch of 250 because of how the
frontend/backend protocol works. So you are seeing some oddities because
of some implementation details and you should not use auto-commit with
batch statements.
Kris Jurka
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: books@ejurka.com, liuhaifeng@live.com, danap@ttc-cmc.net, pgsql-jdbc@postgresql.org
Subject: Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
In-Reply-To: <alpine.BSO.2.00.1212141147030.30031@leary.csoft.net>
References: <BLU0-SMTP1143B3C57133A122263A47AB94E0@phx.gbl> <BLU0-SMTP23378AE609963CCB543ED38B94D0@phx.gbl> <50CB4C40.7000104@ttc-cmc.net> <BLU0-SMTP1534C0E74C7BF8FD348BE51B94D0@phx.gbl> <alpine.BSO.2.00.1212141147030.30031@leary.csoft.net>
* 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