Monday, March 10, 2008

Libpq vs Libpqxx

Libpq is the C application programmer's interface to PostgreSQL, and Libpqxx is the C++ application programmer's interface to PostgreSQL. Libpqxx actually wraps the functions in Libpq. However, Libpqxx is slower than Libpq, and Libpqxx 2.6.9 is not compatible with PostgreSQL 8.3 and GCC 4.1.x on Red Hat / Fedora 5.

After using Libpqxx for the past 5 years on a PostgreSQL 7.4 database, I migrated the database to 8.3 and Libpqxx to the current stable version - 2.6.9. I am running dual quad-core Xeon processors on a 64-bit Red Hat Enterprise 5 Server with GCC 4.1.x. Libpqxx is just a wrapper library around Libpq. There are performance issues because Libpq can be called directly without incurring object / template overhead. After deciding to migrate our codebase to use Libpq, I was very pleased with the results. Error checking is simple, code execution is faster, and library / executable sizes were reduced.