Re: [SQL] update by one transaction - Mailing list pgsql-sql

From dave madden
Subject Re: [SQL] update by one transaction
Date
Msg-id 199806111706.KAA18099@paradigm.webvision.com
Whole thread Raw
In response to update by one transaction  (Lendvary Gyorgy <gyurika@prolan.hu>)
List 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.

pgsql-sql by date:

Previous
From: Lendvary Gyorgy
Date:
Subject: update by one transaction
Next
From: M Simms
Date:
Subject: sequence problems