pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
libpq vs. unixODBC performance
2+ messages / 2 participants
[nested] [flat]

* libpq vs. unixODBC performance
@ 2006-01-21 23:49  Constantine Filin <cfilin@intermedia.net>
  0 siblings, 1 reply; 2+ messages in thread

From: Constantine Filin @ 2006-01-21 23:49 UTC (permalink / raw)
  To: pgsql-performance

Greetings -

I am really love Postgres and do enjoy hacking around it but I just
met a libpq performance issue that I would like to get your help with.

I have Postgres 8.0.1 running on Linux version 2.6.10-1.771_FC2.

I have an application that makes queries to Postgres. I want to keep
the database code in this application as simple as possible because
the application is doing lots of other complex things (it is an IP
Telephony server). So for the sake of simplicity, I do not "prepare"
SQL statements before submitting them to database.

Now I have 2 ways to access Postgres - one through unixODBC, the 
other through libpq. I found that libpq performance is nearly 2 times
slower than performance of unixODBC. Specifically, I have a
multithreaded
test program (using pthreads), where I can run a specified number of
simple queries like this:

SELECT * FROM extensions WHERE 
	(somecolumn IS NOT NULL) 
	AND (id IN (SELECT extension_id FROM table 2))

The test program can submit the queries using unixODBC or libpq. 

With 1 execution thread I have these performance results:
ODBC:  does 200 queries in 2 seconds (100.000000 q/s)
libpq: does 200 queries in 3 seconds (66.666667 q/s)

With 2 threads the results are:
ODBC:  does 200 queries in 3 seconds (66.666667 q/s)
Libpq: does 200 queries in 6 seconds (33.333333 q/s)

With 3 threads:
ODBC: does 200 queries in 5 seconds (40.000000 q/s)
Libpq: 200 queries in 9 seconds (22.222222 q/s)

Obviously libpq is slower.

Do you have any ideas why libpq is so much slower than unixODBC?
Where do you think the libpq bottleneck is? Are there any libpq
options (compile time or runtime) that can make it faster?

Respectfully

Constantine




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: libpq vs. unixODBC performance
@ 2006-01-22 00:40  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Constantine Filin <cfilin@intermedia.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2006-01-22 00:40 UTC (permalink / raw)
  To: Constantine Filin <cfilin@intermedia.net>; +Cc: pgsql-performance

"Constantine Filin" <cfilin@intermedia.net> writes:
> Do you have any ideas why libpq is so much slower than unixODBC?

Perhaps ODBC is batching the queries into a transaction behind your
back?  Or preparing them for you?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-01-22 00:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-21 23:49 libpq vs. unixODBC performance Constantine Filin <cfilin@intermedia.net>
2006-01-22 00:40 ` Tom Lane <tgl@sss.pgh.pa.us>

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