Re: ECPG multiple INSERTS or SELECTS in one command?

From: <wespvp(at)syntegra(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: ECPG multiple INSERTS or SELECTS in one command?
Date: 2004-05-21 14:38:17
Message-ID: BCD37E89.D866%wespvp@syntegra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

>> A (different) Pro*C program I recently ported from Oracle to PostgreSQL
>> showed this difference. In Pro*C you can load an array with rows to insert,
>> then issue a single INSERT request passing it the array. I believe the same
>> thing applies to FETCH. As far as I can tell, in PostgreSQL ecpg (or other)
>> you have to execute one request per record. The program SEGV'd all over the
>> place when I tried to use the Pro*C array code. I had to do a major rework
>> of the code to remove the array logic.
>
> That is for insert right?

Yes, correct.

> Batching inserts is tricky as there is no way
> for ecpg to see if your array of 10 ints shall be inserted as 10 ints or
> as one array.

Perhaps there is some way a flag could be passed as part of the SQL
statement to ecpg to differentiate this? I suspect (but have no easy way of
proving) the lack of this feature may be why there is a 2:1 difference
between loading the same table with Oracle Pro*C and PostgreSQL (Oracle is
twice as fast). With Oracle, I populate an array and do a batch load. With
PostgreSQL, I have to load a row at a time.

> With fetch on the other hand it should work the same as with Pro*C.
> There is no problem to fetch into an array.

Someone on the Interfaces list sent me some sample code. I had made the
rash assumption that since I had to convert all the Pro*C array (INSERT)
code to non-array, that array usage wasn't supported at all by ecpg.

Wes

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Greg Sabino Mullane 2004-05-22 01:00:30 Re: Error code handling in perl
Previous Message Michael Meskes 2004-05-21 13:56:18 Re: ECPG multiple INSERTS or SELECTS in one command?