pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arnaud Lesauvage <arnaud.listes@codata.eu>
To: Relyea, Mike <Mike.Relyea@xerox.com>
To: pgsql-odbc@postgresql.org
Subject: Re: How to speedup inserts via ADO ?
Date: Wed, 17 Feb 2010 11:48:22 +0100
Message-ID: <4B7BC976.3040705@codata.eu> (raw)
In-Reply-To: <AF7D9319B29A0242A33C3BF843BD313309F5427D@USA7061MS03.na.xerox.net>
References: <4B753720.9060901@codata.eu>
	<4B7A17C0.5080309@tpf.co.jp>
	<4B7A68B6.2040302@codata.eu>
	<4B7AADFD.5000905@codata.eu>
	<AF7D9319B29A0242A33C3BF843BD313309F54264@USA7061MS03.na.xerox.net>
	<4B7AB16E.4010807@codata.eu>
	<AF7D9319B29A0242A33C3BF843BD313309F54268@USA7061MS03.na.xerox.net>
	<4B7AB6F7.8040607@codata.eu>
	<AF7D9319B29A0242A33C3BF843BD313309F5427D@USA7061MS03.na.xerox.net>

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



view thread (8+ messages)

Message-ID: <4B7BC976.3040705@codata.eu>
Permalink:  ../4B7BC976.3040705@codata.eu/
Also on:    postgresql.org/message-id/4B7BC976.3040705@codata.eu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: arnaud.listes@codata.eu, Mike.Relyea@xerox.com
  Subject: Re: How to speedup inserts via ADO ?
  In-Reply-To: <4B7BC976.3040705@codata.eu>
  References: <4B753720.9060901@codata.eu> <4B7A17C0.5080309@tpf.co.jp> <4B7A68B6.2040302@codata.eu> <4B7AADFD.5000905@codata.eu> <AF7D9319B29A0242A33C3BF843BD313309F54264@USA7061MS03.na.xerox.net> <4B7AB16E.4010807@codata.eu> <AF7D9319B29A0242A33C3BF843BD313309F54268@USA7061MS03.na.xerox.net> <4B7AB6F7.8040607@codata.eu> <AF7D9319B29A0242A33C3BF843BD313309F5427D@USA7061MS03.na.xerox.net> <4B7BC976.3040705@codata.eu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox