pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andriy Rysin <andriy.rysin@sas.com>
To: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: pgsqlodbc 09_00_0200 is twice as slow on inserts as jdbc driver
Date: Wed, 22 Dec 2010 12:30:34 -0500
Message-ID: <4D1235BA.90007@sas.com> (raw)
In-Reply-To: <4D1175C0.3070709@tpf.co.jp>
References: <3D66EBA5D043E34AADB194828BD4468F1F0714B1@MERCMBX03D.na.SAS.com>
	<4D10FBB1.70104@gmail.com>
	<4D110C7A.6090103@sas.com>
	<4D113D1E.4080405@tpf.co.jp>
	<4D11739E.5000907@sas.com>
	<4D1175C0.3070709@tpf.co.jp>

On 12/21/2010 10:51 PM, Hiroshi Inoue wrote:
> (2010/12/22 12:42), Andriy Rysin wrote:
>> On 12/21/2010 6:49 PM, Hiroshi Inoue wrote:
>>> (2010/12/22 5:22), Andriy Rysin wrote:
>>>> On 12/21/2010 2:10 PM, Adrian Klaver wrote:
>>>>> One to thing look at is whether you have logging turned on in ODBC,
>>>>> this really slows things down. In any case I have never found ODBC to
>>>>> be particularly fast in comparison to other interfaces.
>>>> well, the tracing is turned off, but I also found two things:
>>>> 1) the DB server has a bit lower CPU load when using ODBC driver 
>>>> (30% vs
>>>> 35% with jdbc) and the machine running the program has a bit higher 
>>>> CPU
>>>> load with (6-7% vs 5% with jdbc)
>>>> 2) pg_stat_activity shows proper prepared statement when using jdbc,
>>>> something like:
>>>> insert into my_table (col1, col2) values ($1, $2)
>>>> but when I use ODBC driver the statement looks like a non-prepared 
>>>> one:
>>>> insert into my_table (col1, col2) values (2024443, E'MYTEXT1')
>>>>
>>>> I wander if pgsql odbc driver does not support prepared statement 
>>>> (or I
>>>> need to turn some flag on)
>>>
>>> Do you call SQLPrepare() for the query?
>>> And are you turning on the *Server side prepare* option?
>> Thanks Hiroshi,
>> I do call SQLPrepare(), SQLBindParameter() and SQLExecut() but I did not
>> set the Server side prepare option. After I did set the option to "1" I
>> got this:
>> 1) the statement in pg_stat_activity looks like "EXECUTE
>> "_PLAN0x2c9afaee80"(10195,'86765865'...)" - still not like it should
>> "insert into my_table (col1, col2) values ($1, $2)"
>
> Hmm, are you setting the Protocol to 7.4+?
Ah, thanks, that was it, I changed the protocol to 7.4 and now I see 
proper server-side prepared statements in pg_stat_activity (for some 
reason still none in pg_prepared_statements). And with this I got about 
10% speedup for my inserts, but it's still twice as slow as jdbc: 68sec 
vs 31sec for jdbc for 75,000 rows insert.

When I turn on logging I see these statements:
...
conn=0x2c9b058650, query='BEGIN'
SSendExecuteRequest: plan_name=_PLAN0x2c9b05fde0 count=0
conn=0x2c9b058650, query='SAVEPOINT _EXEC_SVP_0x2c9b05fde0'
SendExecuteRequest: plan_name=_PLAN0x2c9b05fde0 count=0
...

I am wandering if this SAVEPOINT for each insert (even though it's one 
big transaction) is what causing the slowdown.

Andriy




view thread (9+ messages)  latest in thread

Message-ID: <4D1235BA.90007@sas.com>
Permalink:  ../4D1235BA.90007@sas.com/
Also on:    postgresql.org/message-id/4D1235BA.90007@sas.com

 · 

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: andriy.rysin@sas.com
  Subject: Re: pgsqlodbc 09_00_0200 is twice as slow on inserts as jdbc driver
  In-Reply-To: <4D1235BA.90007@sas.com>
  References: <3D66EBA5D043E34AADB194828BD4468F1F0714B1@MERCMBX03D.na.SAS.com> <4D10FBB1.70104@gmail.com> <4D110C7A.6090103@sas.com> <4D113D1E.4080405@tpf.co.jp> <4D11739E.5000907@sas.com> <4D1175C0.3070709@tpf.co.jp> <4D1235BA.90007@sas.com>

* 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