pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedodbc vs. libpq performance
7+ messages / 2 participants
[nested] [flat]
* odbc vs. libpq performance
@ 2015-04-01 18:50 Vilches, Alejandro <alejandro.vilches@intel.com>
0 siblings, 1 reply; 7+ messages in thread
From: Vilches, Alejandro @ 2015-04-01 18:50 UTC (permalink / raw)
To: pgsql-odbc
Hi,
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.
At first I thought that auto-commit was enabled in ODBC, but I went back and made sure to set auto-commit off and performance remained the same:
"SQLSetConnectAttr(handle, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0);"
So I'm wondering if I'm not setting the auto-commit property correctly, or if I'm doing something wrong with ODBC (perhaps not using the right settings), or if there is an issue in the PostgreSQL ODBC driver.
I searched the archives and found one possibly related issue: http://www.postgresql.org/message-id/f147cdfff1924e52926ef90d26971476@EXCH2013.mustinformatique.fr. However, I tried the solution they proposed there, but it didn't improve my issue.
Any help is greatly appreciated! Thanks!
Alejandro
Important details:
* About my program
o Written in C/C++
o Compiled with GCC 4.4.7
o The program basically spawns a given number of threads, each one establishes its own connection to the DB and then performs 100 transactions
o Each transaction simply consists of performing 25 inserts into a single table
o The program uses prepared statements
o The program can connect via ODBC or via libpq
o Both the program and the DB run on the same system, but connect via TCP
* PostgreSQL version: "PostgreSQL 9.3.6 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11), 64-bit"
* PostgreSQL installation: followed the YUM installation instructions for Red Hat here: https://wiki.postgresql.org/wiki/YUM_Installation
* No important changes to postgresql.conf file
* OS:
o Red Hat 6.3
o Linux 2.6.32-279.el6.x86_64 #1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
* Connection:
o Using unixODBC 2.2.14
o PostgreSQL ODBC driver: 09.03.0300
o My DSN configuration:
? Description = My test DB
? Driver = <path to PostgreSQL ODBC driver>
? Trace = No
? TraceFile =
? Servername = localhost
? Database = mytestdb
? Port = 5432
? UseServerSidePrepare = 1
? ReadOnly = No
? RowVersioning = No
? ShowSystemTables = No
? ShowOidColumn = No
? FakeOidIndex = No
? ConnSettings =
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: odbc vs. libpq performance
@ 2015-04-16 00:30 Vilches, Alejandro <alejandro.vilches@intel.com>
parent: Vilches, Alejandro <alejandro.vilches@intel.com>
0 siblings, 1 reply; 7+ messages in thread
From: Vilches, Alejandro @ 2015-04-16 00:30 UTC (permalink / raw)
To: pgsql-odbc
Hi,
Sorry to resend, just hoping someone could take a look and let me know if this is an issue with the PostgreSQL ODBC driver.
Thanks!
Alejandro
From: pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Vilches, Alejandro
Sent: Wednesday, April 1, 2015 11:51 AM
To: 'pgsql-odbc@postgresql.org'
Subject: [ODBC] odbc vs. libpq performance
Hi,
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.
At first I thought that auto-commit was enabled in ODBC, but I went back and made sure to set auto-commit off and performance remained the same:
"SQLSetConnectAttr(handle, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0);"
So I'm wondering if I'm not setting the auto-commit property correctly, or if I'm doing something wrong with ODBC (perhaps not using the right settings), or if there is an issue in the PostgreSQL ODBC driver.
I searched the archives and found one possibly related issue: http://www.postgresql.org/message-id/f147cdfff1924e52926ef90d26971476@EXCH2013.mustinformatique.fr. However, I tried the solution they proposed there, but it didn't improve my issue.
Any help is greatly appreciated! Thanks!
Alejandro
Important details:
* About my program
o Written in C/C++
o Compiled with GCC 4.4.7
o The program basically spawns a given number of threads, each one establishes its own connection to the DB and then performs 100 transactions
o Each transaction simply consists of performing 25 inserts into a single table
o The program uses prepared statements
o The program can connect via ODBC or via libpq
o Both the program and the DB run on the same system, but connect via TCP
* PostgreSQL version: "PostgreSQL 9.3.6 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11), 64-bit"
* PostgreSQL installation: followed the YUM installation instructions for Red Hat here: https://wiki.postgresql.org/wiki/YUM_Installation
* No important changes to postgresql.conf file
* OS:
o Red Hat 6.3
o Linux 2.6.32-279.el6.x86_64 #1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
* Connection:
o Using unixODBC 2.2.14
o PostgreSQL ODBC driver: 09.03.0300
o My DSN configuration:
? Description = My test DB
? Driver = <path to PostgreSQL ODBC driver>
? Trace = No
? TraceFile =
? Servername = localhost
? Database = mytestdb
? Port = 5432
? UseServerSidePrepare = 1
? ReadOnly = No
? RowVersioning = No
? ShowSystemTables = No
? ShowOidColumn = No
? FakeOidIndex = No
? ConnSettings =
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: odbc vs. libpq performance
@ 2015-04-16 07:14 Heikki Linnakangas <hlinnaka@iki.fi>
parent: Vilches, Alejandro <alejandro.vilches@intel.com>
0 siblings, 1 reply; 7+ messages in thread
From: Heikki Linnakangas @ 2015-04-16 07:14 UTC (permalink / raw)
To: Vilches, Alejandro <alejandro.vilches@intel.com>; pgsql-odbc
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
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: odbc vs. libpq performance
@ 2015-07-14 22:20 Vilches, Alejandro <alejandro.vilches@intel.com>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 7+ messages in thread
From: Vilches, Alejandro @ 2015-07-14 22:20 UTC (permalink / raw)
To: hlinnaka@iki.fi <hlinnaka@iki.fi>; 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@gmail.com] On Behalf Of Heikki Linnakangas
Sent: Thursday, April 16, 2015 12:15 AM
To: Vilches, Alejandro; 'pgsql-odbc@postgresql.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
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
odbc_test.cpp (text/plain, 9.9K) download
#include <cstdlib>
#include <cstddef>
#include <cstdio>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <sqltypes.h>
#include <sql.h>
#include <sqlext.h>
#include <iostream>
#include <vector>
#include <memory>
#include <sstream>
const int NUM_THREADS = 2;
const int NUM_OPS_PER_TRANSACTION = 25;
const int NUM_TRANSACTIONS = 100;
// TODO: set user, password and DSN
const char *USER = "";
const char *PASSWORD = "";
const char *DSN = "";
struct tester_work_area {
int thread_num;
bool success;
tester_work_area(int thread_num): thread_num(thread_num)
{
success = false;
}
};
typedef std::shared_ptr<tester_work_area> tester_work_area_ptr;
const int NUM_COLS = 6;
typedef struct {
int attr1;
int attr2;
int attr3;
double attr4;
timeval attr5;
char attr5_str[40];
char attr6[257];
} row_t;
void *tester(void *work_area);
void generate_row(row_t *row);
void to_sql_timestamp(SQL_TIMESTAMP_STRUCT *sql_timestamp, const timeval *tv);
std::string error_info(SQLSMALLINT handle_type, SQLHANDLE handle);
int main()
{
std::vector<pthread_t> threads;
pthread_t thread_id;
pthread_attr_t attr;
int rc;
void *status;
std::vector<tester_work_area_ptr> work_areas;
tester_work_area_ptr wa;
struct timeval start_time;
struct timeval end_time;
struct timeval diff;
double total_time;
int total_transactions = NUM_THREADS * NUM_TRANSACTIONS;
double tps_overall;
srand(time(NULL));
std::cout << "Number of transactions: " << NUM_TRANSACTIONS << std::endl;
std::cout << "Number of operations per transaction: "
<< NUM_OPS_PER_TRANSACTION << std::endl;
std::cout << "Number of threads: " << NUM_THREADS << std::endl;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
gettimeofday(&start_time, NULL);
for (int t = 0; t < NUM_THREADS; t++) {
wa.reset(new tester_work_area(t));
work_areas.push_back(wa);
rc = pthread_create(&thread_id, &attr, tester, (void *)wa.get());
if (rc != 0) {
std::cerr << "Unable to create thread " << t <<
": pthread_create returned: " << rc << std::endl;
return 1;
}
threads.push_back(thread_id);
}
pthread_attr_destroy(&attr);
for (int t = 0; t < NUM_THREADS; t++) {
rc = pthread_join(threads[t], &status);
if (rc != 0) {
std::cerr << "Unable to join thread " << t <<
": pthread_join returned: " << rc << std::endl;
return 1;
}
}
gettimeofday(&end_time, NULL);
for (std::vector<tester_work_area_ptr>::const_iterator it =
work_areas.begin(); it != work_areas.end(); ++it) {
if (!(*it)->success) {
std::cerr << "Unable to compute performance results as one or " <<
"more threads did not complete successfully" << std::endl;
return 1;
}
}
diff.tv_sec = end_time.tv_sec - start_time.tv_sec;
diff.tv_usec = end_time.tv_usec - end_time.tv_usec;
while (diff.tv_usec < 0) {
diff.tv_usec += 1000000;
diff.tv_sec--;
}
while (diff.tv_usec >= 1000000) {
diff.tv_usec -= 1000000;
diff.tv_sec++;
}
total_time = (double)diff.tv_sec + (double)diff.tv_usec / 1000000.0;
tps_overall = (double)total_transactions / total_time;
std::cout << "Total time: " << total_time << "s" << std::endl;
std::cout << "Transaction throughput: " << tps_overall << "tps"
<< std::endl;
return 0;
}
#define ON_ODBC_ERROR(rc, fmt, ...) \
if (!SQL_SUCCEEDED(rc)) { \
fprintf(stderr, fmt, ##__VA_ARGS__); \
pthread_exit(NULL); \
}
void *tester(void *work_area)
{
tester_work_area *my_work_area = (tester_work_area *)work_area;
SQLHENV env_handle;
SQLHDBC db_handle;
SQLHSTMT stmt_handle;
SQLRETURN ret;
row_t row;
SQL_TIMESTAMP_STRUCT attr5;
// Prepare environment handle
ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env_handle);
ON_ODBC_ERROR(ret, "Thread %d: unable to allocate environment handle",
my_work_area->thread_num);
ret = SQLSetEnvAttr(env_handle, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3, 0);
ON_ODBC_ERROR(ret, "Thread %d: unable to set environment attributes",
my_work_area->thread_num);
// Prepare connection handle
ret = SQLAllocHandle(SQL_HANDLE_DBC, env_handle, &db_handle);
ON_ODBC_ERROR(ret, "Thread %d: unable to allocate connection handle",
my_work_area->thread_num);
ret = SQLSetConnectAttr(db_handle, SQL_ATTR_LOGIN_TIMEOUT,
(SQLPOINTER)5, 0);
ON_ODBC_ERROR(ret, "Thread %d: unable to set connection attributes",
my_work_area->thread_num);
ret = SQLSetConnectAttr(db_handle, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_OFF, 0);
ON_ODBC_ERROR(ret, "Thread %d: unable to set connection attributes",
my_work_area->thread_num);
// Connect to the database
ret = SQLConnect(db_handle, (SQLCHAR *)DSN, SQL_NTS, (SQLCHAR *)USER,
SQL_NTS, (SQLCHAR *)PASSWORD, SQL_NTS);
ON_ODBC_ERROR(ret, "Thread %d: unable to connect to the database",
my_work_area->thread_num);
// Prepare the SQL statement handle
ret = SQLAllocHandle(SQL_HANDLE_STMT, db_handle, &stmt_handle);
ON_ODBC_ERROR(ret, "Thread %d: unable to allocate statement handle",
my_work_area->thread_num);
// Prepare the SQL statement
ret = SQLPrepare(stmt_handle,
(SQLCHAR *)"insert into test_table(attr1_int, attr2_int, "
"attr3_int, attr4_double, attr5_time, attr6_str) values ( "
"?, ?, ?, ?, ?, ?)", SQL_NTS);
ON_ODBC_ERROR(ret, "Thread %d: unable to prepare statement",
my_work_area->thread_num);
// Bind the parameters
ret = SQLBindParameter(stmt_handle, 1, SQL_PARAM_INPUT, SQL_C_LONG,
SQL_INTEGER, 0, 0, (SQLPOINTER)&row.attr1, 0, NULL);
ON_ODBC_ERROR(ret, "Thread %d: unable to bind parameter 1",
my_work_area->thread_num);
ret = SQLBindParameter(stmt_handle, 2, SQL_PARAM_INPUT, SQL_C_LONG,
SQL_INTEGER, 0, 0, (SQLPOINTER)&row.attr2, 0, NULL);
ON_ODBC_ERROR(ret, "Thread %d: unable to bind parameter 2",
my_work_area->thread_num);
ret = SQLBindParameter(stmt_handle, 3, SQL_PARAM_INPUT, SQL_C_LONG,
SQL_INTEGER, 0, 0, (SQLPOINTER)&row.attr3, 0, NULL);
ON_ODBC_ERROR(ret, "Thread %d: unable to bind parameter 3",
my_work_area->thread_num);
ret = SQLBindParameter(stmt_handle, 4, SQL_PARAM_INPUT, SQL_C_DOUBLE,
SQL_DOUBLE, 0, 0, (SQLPOINTER)&row.attr4, 0, NULL);
ON_ODBC_ERROR(ret, "Thread %d: unable to bind parameter 4",
my_work_area->thread_num);
ret = SQLBindParameter(stmt_handle, 5, SQL_PARAM_INPUT,
SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 0, 0, (SQLPOINTER)&attr5,
sizeof(attr5), NULL);
ON_ODBC_ERROR(ret, "Thread %d: unable to bind parameter 5",
my_work_area->thread_num);
ret = SQLBindParameter(stmt_handle, 6, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_VARCHAR, 0, 0, (SQLPOINTER)row.attr6, sizeof(row.attr6), NULL);
ON_ODBC_ERROR(ret, "Thread %d: unable to bind parameter 6",
my_work_area->thread_num);
for (int i = 0; i < NUM_TRANSACTIONS; i++) {
for (int j = 0; j < NUM_OPS_PER_TRANSACTION; j++) {
generate_row(&row);
to_sql_timestamp(&attr5, &row.attr5);
ret = SQLExecute(stmt_handle);
ON_ODBC_ERROR(ret, "Thread %d: unable to execute statement; ODBC "
"error info:\n%s", my_work_area->thread_num,
error_info(SQL_HANDLE_STMT, stmt_handle).c_str());
}
ret = SQLEndTran(SQL_HANDLE_DBC, db_handle, SQL_COMMIT);
ON_ODBC_ERROR(ret, "Thread %d: unable to commit transaction; ODBC "
"error info:\n%s", my_work_area->thread_num,
error_info(SQL_HANDLE_STMT, stmt_handle).c_str());
}
my_work_area->success = true;
pthread_exit(NULL);
return NULL;
}
void generate_row(row_t *row)
{
std::ostringstream oss;
std::size_t len;
row->attr1 = rand();
row->attr2 = rand();
row->attr3 = rand();
row->attr4 = rand() / (double)RAND_MAX;
gettimeofday(&row->attr5, NULL);
strftime(row->attr5_str, sizeof(row->attr5_str), "%F %T",
localtime(&row->attr5.tv_sec));
oss << "New row generated at time: " << row->attr5_str;
len = oss.str().copy(row->attr6, sizeof(row->attr6) - 1);
row->attr6[len] = '\0';
}
void to_sql_timestamp(SQL_TIMESTAMP_STRUCT *sql_timestamp, const timeval *tv)
{
tm *time_info = localtime(&tv->tv_sec);
sql_timestamp->year = time_info->tm_year + 1900;
sql_timestamp->month = time_info->tm_mon + 1;
sql_timestamp->day = time_info->tm_mday;
sql_timestamp->hour = time_info->tm_hour;
sql_timestamp->minute = time_info->tm_min;
sql_timestamp->second = time_info->tm_sec;
sql_timestamp->fraction = tv->tv_usec * 1000;
}
std::string error_info(SQLSMALLINT handle_type, SQLHANDLE handle)
{
std::ostringstream ss;
SQLCHAR sql_state[6];
SQLINTEGER native_error;
SQLCHAR msg[SQL_MAX_MESSAGE_LENGTH];
SQLSMALLINT msg_len;
int i = 1;
int ret;
ret = SQLGetDiagRec(handle_type, handle, i, sql_state, &native_error, msg,
sizeof(msg), &msg_len);
if (!(SQL_SUCCEEDED(ret))) {
return std::string("unable to retrieve ODBC error information");
}
do {
ss << "Status record: " << i << std::endl;
ss << "SQL state: " << sql_state << std::endl;
ss << "Native error: " << native_error << std::endl;
ss << "Message: " << msg << std::endl;
i++;
ret = SQLGetDiagRec(handle_type, handle, i, sql_state, &native_error,
msg, sizeof(msg), &msg_len);
} while (SQL_SUCCEEDED(ret));
return ss.str();
}
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: odbc vs. libpq performance
@ 2015-07-30 23:33 Vilches, Alejandro <alejandro.vilches@intel.com>
parent: Vilches, Alejandro <alejandro.vilches@intel.com>
0 siblings, 1 reply; 7+ messages in thread
From: Vilches, Alejandro @ 2015-07-30 23:33 UTC (permalink / raw)
To: Vilches, Alejandro <alejandro.vilches@intel.com>; hlinnaka@iki.fi <hlinnaka@iki.fi>; 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@postgresql.org [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Vilches, Alejandro
Sent: Tuesday, July 14, 2015 3:20 PM
To: hlinnaka@iki.fi; 'pgsql-odbc@postgresql.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@gmail.com] On Behalf Of Heikki Linnakangas
Sent: Thursday, April 16, 2015 12:15 AM
To: Vilches, Alejandro; 'pgsql-odbc@postgresql.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
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: odbc vs. libpq performance
@ 2015-08-01 18:06 Heikki Linnakangas <hlinnaka@iki.fi>
parent: Vilches, Alejandro <alejandro.vilches@intel.com>
0 siblings, 1 reply; 7+ messages in thread
From: Heikki Linnakangas @ 2015-08-01 18:06 UTC (permalink / raw)
To: Vilches, Alejandro <alejandro.vilches@intel.com>; pgsql-odbc
On 07/31/2015 02:33 AM, Vilches, Alejandro wrote:
> 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?
A-ha! Yes, that's a bug in the driver. In fact, it was fixed back in
January:
http://www.postgresql.org/message-id/BY1PR0401MB143087AD121D0251C00E5045A85B0@BY1PR0401MB1430.namprd...
That fix will be included in the next release.
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: odbc vs. libpq performance
@ 2015-08-05 00:04 Vilches, Alejandro <alejandro.vilches@intel.com>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 0 replies; 7+ messages in thread
From: Vilches, Alejandro @ 2015-08-05 00:04 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-odbc
(Sorry, didn't reply to the mailing list initially.)
Oh, great! Thanks for letting me know!
Now, even when setting auto commit to off, performance is still significantly lower (compared to libpq). For example, running the sample program I provided earlier on my machine (and setting auto commit to off), I'm a getting ~100 transactions per second. I did see an improvement compared to before (when I wasn't able to set auto commit to off) as I was only getting ~4 transactions per second. However, if I change the program to use libpq, I get ~1400 transactions per second. I was expecting to see better performance, but the difference shouldn't be too significant, right? What performance difference should I expect when using ODBC vs libpq?
Thanks!
Alejandro
-----Original Message-----
From: Heikki Linnakangas [mailto:hlinnaka@gmail.com] On Behalf Of Heikki Linnakangas
Sent: Saturday, August 1, 2015 11:07 AM
To: Vilches, Alejandro; 'pgsql-odbc@postgresql.org'
Subject: Re: [ODBC] odbc vs. libpq performance
On 07/31/2015 02:33 AM, Vilches, Alejandro wrote:
> 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?
A-ha! Yes, that's a bug in the driver. In fact, it was fixed back in
January:
http://www.postgresql.org/message-id/BY1PR0401MB143087AD121D0251C00E5045A85B0@BY1PR0401MB1430.namprd...
That fix will be included in the next release.
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2015-08-05 00:04 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 18:50 odbc vs. libpq performance Vilches, Alejandro <alejandro.vilches@intel.com>
2015-04-16 00:30 ` Vilches, Alejandro <alejandro.vilches@intel.com>
2015-04-16 07:14 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-14 22:20 ` Vilches, Alejandro <alejandro.vilches@intel.com>
2015-07-30 23:33 ` Vilches, Alejandro <alejandro.vilches@intel.com>
2015-08-01 18:06 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-05 00:04 ` Vilches, Alejandro <alejandro.vilches@intel.com>
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