From: Michael Meskes <meskes@postgresql.org>
To: Jorma O. Tähtinen <jotahtin@alpha.hut.fi>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: ecpg: how select/insert n rows (array) in one query
Date: Wed, 14 Jun 2000 17:21:36 +0200
Message-ID: <20000614172136.A1866@fam-meskes.de> (raw)
In-Reply-To: <39425586.2E418BAC@alpha.hut.fi>
References: <39425586.2E418BAC@alpha.hut.fi>
On Sat, Jun 10, 2000 at 05:49:42PM +0300, Jorma O. Tähtinen wrote:
> 1) select - this is simple (well documented)
> ...
> EXEC SQL BEGIN DECLARE SECTION;
> struct data_t {
> char md5[100][32];
> int size[100];
> } data;
> ...
> Only question here is: why can't I declare that data struct like
> struct data_t {
> char md5[32];
> int size;
> } data[100];
> Is this possible and how to use it.
Hmm, it certainly should be possible. I will look into it as soon as I find
some spare time. I do not remember if there was a real problem with this.
> if I have understod docs correctly : use of insert like select in
> about example is NOT possible
> please somebody say that I'm wrong - small example would be nice to
> see ;-)
selects work because the backend returns more than one tuple at a time.
However, inserts do not work that way. An SQL insert command is designed to
insert one tuple. I wouldn't know which syntax to use to do that sort of
bulk loading.
> And yes I have tried to insert multiple rows in one transaction
> block like
> EXEC SQL BEGIN TRANSACTION
> for(....) {
> insert .....
> }
> EXEC SQL COMMIT
>
> but this is still way to slow at max 50-100 insert per sec. I
> understand that inserting is slow operation
Try starting the backend without -F and putting each insert into its own
transaction. Keeping lots of updates/insert in one transaction always slows
down a system. The very same would happen to mysql if it used transactions.
> And yes, I really want to use c+embedded sql code to do inserting
> (real app/table struct of course more complex)
If this is a ecpg problem we surely will fix it. But I doubt the performance
is better when using psql to enter the data.
Michael
--
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: meskes@postgresql.org, jotahtin@alpha.hut.fi
Subject: Re: ecpg: how select/insert n rows (array) in one query
In-Reply-To: <20000614172136.A1866@fam-meskes.de>
* 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