X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 86FB1D1B1FD for ; Fri, 23 Jul 2004 13:26:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11856-10 for ; Fri, 23 Jul 2004 16:26:11 +0000 (GMT) Received: from web25105.mail.ukl.yahoo.com (web25105.mail.ukl.yahoo.com [217.12.10.53]) by svr1.postgresql.org (Postfix) with SMTP id 81E3CD1B1B8 for ; Fri, 23 Jul 2004 13:26:09 -0300 (ADT) Message-ID: <20040723162608.84118.qmail@web25105.mail.ukl.yahoo.com> Received: from [217.158.107.104] by web25105.mail.ukl.yahoo.com via HTTP; Fri, 23 Jul 2004 17:26:08 BST Date: Fri, 23 Jul 2004 17:26:08 +0100 (BST) From: =?iso-8859-1?q?Gary=20Cowell?= Subject: Re: Performance over a LAN To: pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/154 X-Sequence-Number: 7545 --- William Carney wrote: > The test program is a C program with embedded SQL > (ecpg). The only > difference between the tests was the address used in > the EXEC SQL CONNECT > .. statement. The inserts are committed to the > database by performing an > EXEC SQL COMMIT after every N of them; I tried > various values of N up to > several hundred, but it didn't make much difference. > Using psql I can see > records appearing in the database in groups of that > size. I'm not sure about > all of the protocol versions. I downloaded the > complete Postgres source and > built it only a few days ago. Ecpg says that it's > version is 3.1.1. I'm not > getting any errors reported anywhere, it's just that > things are surprisingly > slow over the LAN for some reason. > > William It's probably the number of round trips to the server. If pg can accept host variable arrays, try using a thousand element array or something to do your inserts. e.g. char mycharhv[1000][10] then set up the mycharhvs[1][..], [2][...] etc and fling them at the database with a single insert statement. I just tried this with the following program: #include exec sql include sqlca; exec sql begin declare section; char db[10]; char inserts[5000][10]; exec sql end declare section; int main(void) { unsigned int n; strcpy(db,"mydb"); exec sql connect to :db; printf("sqlcode connect %i\n",sqlca.sqlcode); for(n=0;n<5000;n++) { strcpy(inserts[n],"hello"); } exec sql insert into gaz values (:inserts); printf("sqlcode insert %i\n",sqlca.sqlcode); exec sql commit work; } This didn't work on pg, I only got one row inserted. This is using ecpg 2.9.0, pg 7.2.2 On Oracle with PRO*C this causes 5000 rows to be written with one insert and is a technique I've used to get better network performance with Oracle. Is this fixed in newer versions? If not, it sounds like a good feature. ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com