pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lendvary Gyorgy <gyurika@prolan.hu>
To: pgsql-sql@postgresql.org
Subject: update by one transaction
Date: Thu, 11 Jun 1998 15:26:57 +0200
Message-ID: <357FDB21.43776016@prolan.hu> (raw)

BEGIN isn't the solution, just I forgot to write it. So I repeat my
problem again:
 
I have a table for instance boci (row_number int, col2 float, col3
float). The boci table has about 10000 rows. 
I want to update col3 column of the table in every row with different
values. Desired values are in an array has 10000 elements. I want to be
the value of the col3 column in the first row equal to the first element
of the array and so on. 
I've done it with a 'for' cycle, but it is very slow. I want to do
theese updates with one transaction. 

Here is a little piece of my program:

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. Is there any way making this program
much faster (for instance with CURSOR or 'block write' or something
else)? Please write me a little program that describes your ideas!

Thanks for your help in advance!

Please help me!!!



view thread (4+ messages)  latest in thread

Message-ID: <357FDB21.43776016@prolan.hu>
Permalink:  ../357FDB21.43776016@prolan.hu/
Also on:    postgresql.org/message-id/357FDB21.43776016@prolan.hu

 · 

reply

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-sql@postgresql.org
  Cc: gyurika@prolan.hu
  Subject: Re: update by one transaction
  In-Reply-To: <357FDB21.43776016@prolan.hu>
  References: <357FDB21.43776016@prolan.hu>

* 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