Re: [SQL] update by one transaction

dave madden <dhm@paradigm.webvision.com>

From: dave madden <dhm@paradigm.webvision.com>
To: gyurika@prolan.hu
Cc: pgsql-sql@postgreSQL.org
Date: 1998-06-11T17:06:19Z
Lists: pgsql-sql
 =>From: Lendvary Gyorgy <gyurika@prolan.hu>
 =>...
 =>PQexec(conn, "BEGIN");
 =>for (i=0; i<10000; i++)
 =>{
 =>    sprintf(buff, "UPDATE boci SET col3 = %f WHERE row_number=%d",
 =>array[i], i);
 =>    PQexec(conn, buff);
 =>}
 =>PQexec(conn, "END");
 =>
 =>This program is very, very slow.

The first thing I'd check is that you have an index on
boci(row_number).  If you do, or if adding one doesn't help, then
perhaps you could split boci into two tables:

		boci1( row_number int, col2 float )
		boci2( row_number int, col3 float )

Then you could use the COPY command to load data from your array.  To
select things, just join boci1 and boci2 on row_number (or create a
view, if PostgreSQL supports 'em).

d.