X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EB613D1B1B6; Fri, 21 May 2004 11:38:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84092-09; Fri, 21 May 2004 11:38:24 -0300 (ADT) Received: from ns1.syntegra.com (ns1.syntegra.com [150.143.16.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6C0D7D1B1BD; Fri, 21 May 2004 11:38:18 -0300 (ADT) Received: from [129.179.161.11] by ns1.syntegra.com with ESMTP; Fri, 21 May 2004 14:38:20 Z Received: from jarjar.arh.cdc.com ([129.179.16.105] [129.179.16.105]) by ah-intrastore-01.us.syntegra.com with ESMTP; Fri, 21 May 2004 09:38:19 -0500 Received: from [129.179.16.111] ([129.179.16.111] [129.179.16.111]) by jarjar.arh.cdc.com with ESMTP; Fri, 21 May 2004 09:36:05 -0500 X-Mailer: Claris Emailer 2.0v3 , January 8, 1998 Date: Fri, 21 May 2004 09:38:17 -0500 Subject: Re: ECPG multiple INSERTS or SELECTS in one command? From: To: Michael Meskes Cc: Message-Id: In-Reply-To: <20040521135618.GD14285@1> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200405/27 X-Sequence-Number: 4919 >> 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