Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 76A6A6335C7 for ; Wed, 17 Feb 2010 06:48:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41493-01 for ; Wed, 17 Feb 2010 10:48:28 +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 B95FA6325F1 for ; Wed, 17 Feb 2010 06:48:28 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by serveurmail01.codata.be (Postfix) with ESMTP id 3D0EC1F38249; Wed, 17 Feb 2010 11:48:26 +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 DdaKtm5t12vs; Wed, 17 Feb 2010 11:48:22 +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 B62861F38228; Wed, 17 Feb 2010 11:48:22 +0100 (CET) Message-ID: <4B7BC976.3040705@codata.eu> Date: Wed, 17 Feb 2010 11:48:22 +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: "Relyea, Mike" , pgsql-odbc@postgresql.org Subject: Re: How to speedup inserts via ADO ? References: <4B753720.9060901@codata.eu> <4B7A17C0.5080309@tpf.co.jp> <4B7A68B6.2040302@codata.eu> <4B7AADFD.5000905@codata.eu> <4B7AB16E.4010807@codata.eu> <4B7AB6F7.8040607@codata.eu> In-Reply-To: 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=0.101 tagged_above=-10 required=5 tests=BAYES_50=0.001, RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 201002/19 X-Sequence-Number: 10206 Le 16/02/2010 16:22, Relyea, Mike a écrit : >> Yes, that's the last option. >> I would have liked something more straightforward but I think >> I'll have to go this way. >> Quite painful to parse the recordset in a plain SQL INSERT >> though, and it feels like doing in VBA exactly what the ODBC >> driver is doing. > > I agree. I've had to do many such workarounds with my own > Access/Postgres database. It's not the way things are 'supposed' to > work but it may end up getting the end result you want. > > A word of caution that I bumped into - passthrough queries have a limit > on the number of characters they can contain. I don't remember what > that limit is off the top of my head but I'd guess somewhere around > 65000. If your insert string(s) are very long you may have to split it > up into more than one passthrough. I wrote a small function that returns a nice SQL-formatted string when passed an ADO Field object (escaped with E'' for strings, NULL for nulls, ISO for dates, etc...). I juste loop through the Fields collection of my recordset, create the SQL string and execute the resulting command directly via Connection.Execute. Speed is OK now, ~15s for 10.000 records so that is only twice slower that direct insert in psql ou pgAdmin. Good enough for me ! Since I juste use a VB string to store the query and pass it to the Execute method, I think the limitation won't apply. VB strings can be very long (2^31 characters I think). Thanks for your help Regards -- Arnaud Lesauvage