Re: odbc vs. libpq performance

From: "Vilches, Alejandro" <alejandro(dot)vilches(at)intel(dot)com>
To: "Vilches, Alejandro" <alejandro(dot)vilches(at)intel(dot)com>, "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-30 23:33:20
Message-ID: 9CE034E149417949A58AA9A4FA7E1C5584AF0A28@ORSMSX109.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

I've continued looking into this and I discovered something: I figured out how to successfully set the SQL_ATTR_AUTOCOMMIT attribute to off. If you set it prior to establishing the connection, this setting is ignored and it defaults to on. If you set it after establishing the connection, then it does recognize the setting and it works as specified.

The ODBC documentation specifies that this attribute can be set either before or after establishing the connection. If it's not accepting the setting before establishing the connection, is this an issue in the PostgreSQL ODBC driver?

-----Original Message-----
From: pgsql-odbc-owner(at)postgresql(dot)org [mailto:pgsql-odbc-owner(at)postgresql(dot)org] On Behalf Of Vilches, Alejandro
Sent: Tuesday, July 14, 2015 3:20 PM
To: hlinnaka(at)iki(dot)fi; 'pgsql-odbc(at)postgresql(dot)org'
Subject: Re: [ODBC] odbc vs. libpq performance

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

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Christian Ullrich 2015-07-31 18:30:50 Bugs related to getting @@identity
Previous Message Raiford 2015-07-30 14:41:59 Re: PSQLODBC.DLL - The (maximum) expected data length is 8000, while the returned data length is 9606.