Re: Thread or not threads?

From: per(at)nospam(dot)mimer(dot)se (Per Schrder)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Thread or not threads?
Date: 2001-05-02 15:46:04
Message-ID: Xns9095B4A108CF8pescatmimer@192.71.97.199
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>
>Raymond Chui <raymond(dot)chui(at)noaa(dot)gov> wrote:

>> 2) Use batched update. Requires a JDBC 2 compliant driver.
>> The purpose is to reduce the number of server roundtrips.

>What is batched update?

PreparedStatement.addBatch() and PreparedStatement.executeBatch().

Something like this:

PreparedStatement ps = con.prepareStatement("INSERT INTO XX VALUES
(?,?,?)");

//later...
for (int i=0; i<100 /*maybe?*/; i++) {
// Get data
ps.setInt(1,ival);
ps.setString(2,sval);
ps.setFloat(3,fval);
ps.addBatch(); // Add one record to the batch
}

// Note! nothing sent to server yet.
int sv[] = ps.executeBatch();
// Now, 100 lines are inserted in one go!
con.commit();
// Commit 100 lines

/Per Schrder
http://developer.mimer.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message newsreader 2001-05-02 15:54:37 Re: disk usage advice needed
Previous Message Fran Fabrizio 2001-05-02 15:24:18 Re: Stranger than fiction - EXPLAIN results