Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D4B09632180 for ; Tue, 16 Feb 2010 05:43:37 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 36242-04 for ; Tue, 16 Feb 2010 09:43:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from serveurmail01.codata.be (113.123.146.82.ipv4.evonet.be [82.146.123.113]) by mail.postgresql.org (Postfix) with ESMTP id 05BD2632B84 for ; Tue, 16 Feb 2010 05:43:27 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by serveurmail01.codata.be (Postfix) with ESMTP id 999111F38233; Tue, 16 Feb 2010 10:43:24 +0100 (CET) X-Virus-Scanned: amavisd-new at Received: from serveurmail01.codata.be ([127.0.0.1]) by localhost (serveurmail01.codata.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wFhedoKxRsuR; Tue, 16 Feb 2010 10:43:18 +0100 (CET) Received: from [127.0.0.1] (38-179-112-217.fix.adsl.belcenter.be [217.112.179.38]) by serveurmail01.codata.be (Postfix) with ESMTP id 9D0711F38229; Tue, 16 Feb 2010 10:43:18 +0100 (CET) Message-ID: <4B7A68B6.2040302@codata.eu> Date: Tue, 16 Feb 2010 10:43:18 +0100 From: Arnaud Lesauvage User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1 MIME-Version: 1.0 To: Hiroshi Inoue CC: pgsql-odbc@postgresql.org Subject: Re: How to speedup inserts via ADO ? References: <4B753720.9060901@codata.eu> <4B7A17C0.5080309@tpf.co.jp> In-Reply-To: <4B7A17C0.5080309@tpf.co.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.849 tagged_above=-10 required=5 tests=AWL=0.650, BAYES_00=-2.599, RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 201002/13 X-Sequence-Number: 10200 Le 16/02/2010 4:57, Hiroshi Inoue a écrit : > Arnaud Lesauvage wrote: >> Inserts via ODBC are a lot slower than via native psql connection. >> For instance, I have a very basic insert statement that inserts one row >> in a table. >> If I execute it 1000 times in pgAdmin, it returns in 718ms. >> If I execute it via ADO (with a direct query : Connection.Execute >> "INSERT INTO..."), it takes 15s to complete. >> >> I checked psqlODBC's commlog, but all I see in it are the INSERT >> statements that I issued. So there must be a lot of overhead somewhere, >> but I don't understand where it comes from, and more important I don't >> understand how I could get rid of it. >> >> Are there some connection parameters that I could use to speed things up ? > > 1. Do inserts in a transction. > 2. Set the "Level of rollback on errors" option to Transacion. > 3. Use a prepared Command object. 1. I think I tried this, but do you mean that I should issue "BEGIN" and "COMMIT" statements manually (via my connection's "execute" method), or should I use ADO's BeginTrans and CommitTrans method on the connection ? 2. OK I think I haven't tried this, I left it to the default setting (no idea what this is) 3. OK I could try this, but the table is very large and this would be very cumbersome to code. That would be a command with about 100 parameters, I'd rather just issue a "INSERT INTO pgsql_table SELECT * FROM local-table". I'll activate mylog also. I thought that commlog was enough but I forgot about mylog. Regards -- Arnaud