Skip site navigation (1) Skip section navigation (2)

Re: number of transactions doubling

From: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
To: Sriram Dandapani <sdandapani(at)counterpane(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: number of transactions doubling
Date: 2006-09-29 00:47:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-adminpgsql-jdbc
On Thu, Sep 28, 2006 at 02:51:24PM -0700, Sriram Dandapani wrote:
> I have a strange problem with the  number of transactions generated
> within my application. I use jdbc batching to submit insert statements
> from a jboss app server to postgres 8.1.2.
> A batch can have from 100 to 3000 inserts.
> I noticed the following:
> When I run the following query
> select current_timestamp,datname,age(datfrozenxid) from pg_database;
> The age columns shows say 1,500,000,000
> When I run the same query after say 10 minutes, it shows 1,500,600,000
> I have issued about 40,000 inserts via jdbc batching in 10 minutes.
> It appears that the jdbc driver is generating twice the number of
> transactions as inserts. This behaviour appears consistent with the
> number of inserts that I generate
Uh... you're inserting 40k rows and getting 600k transactions... how are
you concluding that the jdbc driver is generating 80k transactions?

> The target table has triggers that route data to appropriate tables. The
> tables to which data is routed has check constraints that do further
> inserts. (All of this happens in 1 jdbc transaction)
Actually, no matter what JDBC is doing, all of that will happen within a
single transaction on the database (unless you're using something like
dblink from within the triggers). So even if you were issuing insert
statements with autocommit on, you'd see at most one transaction per

> I expect  JDBC Batching to generate fewer transactions depending on
> batch size.
> The mystery is why am I seeing double the number of transactions being
> generated.
> This is causing transaction id wraparound limits to be approached
> quicker than I would like.

As for your autocommit bit-flipping, why don't you just issue either a
rollback or a commit when you release the connection?
Jim Nasby                                            jim(at)nasby(dot)net
EnterpriseDB      512.569.9461 (cell)

In response to


pgsql-admin by date

Next:From: Jim C. NasbyDate: 2006-09-29 00:50:38
Subject: Re: Addendum on stored procedure array limits
Previous:From: Jim C. NasbyDate: 2006-09-29 00:40:42
Subject: Re: transaction id wraparound

pgsql-jdbc by date

Next:From: Heikki LinnakangasDate: 2006-09-29 08:56:15
Subject: Re: [JDBC] number of transactions doubling
Previous:From: Oliver JowettDate: 2006-09-28 23:13:41
Subject: Re: [JDBC] number of transactions doubling

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group