Re: odbc vs. libpq performance

From: "Vilches, Alejandro" <alejandro(dot)vilches(at)intel(dot)com>
To: "hlinnaka(at)iki(dot)fi" <hlinnaka(at)iki(dot)fi>, "'pgsql-odbc(at)postgresql(dot)org'" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: odbc vs. libpq performance
Date: 2015-07-14 22:20:04
Message-ID: 9CE034E149417949A58AA9A4FA7E1C5584AC9707@ORSMSX109.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hi Heikki,

Sorry for taking so long to reply, I was away for a while and came back just recently.

So, before addressing your questions, I discovered something interesting: when connecting via ODBC, transactions are being committed automatically (even though I'm setting SQL_ATTR_AUTOCOMMIT to SQL_AUTOCOMMIT_OFF). This would explain the poor performance I've been seeing.

To address your questions:
I'm attaching my little test program connecting via ODBC. To run it you'll need to create the table (which is pretty simple as you'll see from the insert statement). You'll also need to set the connection parameters. Finally, you can play with the number of threads to try to get different performance results. To compile you'll need "-lodbc -lpthread -std=c++0x".

So, I'm wondering: am I just setting the auto commit parameter incorrectly or is it possible that there is a bug (either in unixODBC or the PostgreSQL ODBC driver)?

I also ran my tests with "log_min_duration_statement = 0" as you suggested. When connecting via ODBC I do see that each insert statement is taking longer (compared to when I connect via libpq).

Let me know if you have any questions or if there is any other information I could provide.

Thanks!
Alejandro

-----Original Message-----
From: Heikki Linnakangas [mailto:hlinnaka(at)gmail(dot)com] On Behalf Of Heikki Linnakangas
Sent: Thursday, April 16, 2015 12:15 AM
To: Vilches, Alejandro; 'pgsql-odbc(at)postgresql(dot)org'
Subject: Re: [ODBC] odbc vs. libpq performance

On 04/16/2015 03:30 AM, Vilches, Alejandro wrote:
> I have a simple program that inserts data into a single table (see details below). When I have the program connect to the DB via ODBC, performance is significantly slower compared to when I have it connect via libpq. I was able to achieve ~1000 transactions per second using libpq, but only ~4 transactions per second using the ODBC driver.

I'd suggest setting log_min_duration_statement = 0 in the server's config file. Then repeat the test and look at the log file to see where the time is spent. If that gives no clue, I'm happy to take a look, if you can reproduce it with a small test program and post it to a list.

- Heikki

Attachment Content-Type Size
odbc_test.cpp text/plain 9.9 KB

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Michael Paquier 2015-07-15 14:52:33 Manifest creation for psqlodbc*.dll
Previous Message intmail01@gmail.com 2015-07-10 09:22:52 Re: utf8 data with strange characters