Difference in query performance when made from C/C++ client vs. psql client.

From: Aditya Rastogi <adirastogi(at)outlook(dot)com>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Difference in query performance when made from C/C++ client vs. psql client.
Date: 2013-09-07 13:15:38
Message-ID: BAY176-W3C969C1105340CF81826BC53D0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,
I am running a postgreSQL database to which multiple C/C++ clients send queries via the libpq interface. On an expensive query doing multiple levels of aggregation on a large dataset, I observe that the CPU usage of the postmaster process goes up to 100 % and the query never completes. However, If I connect to the database via the psql terminal client and execute the same query on the same data set, it takes only a few milliseconds to complete (with the top command showing only a momentary spike in the CPU usage of the postmaster process), irrespective of the size of the underlying data set. Moreover , for a very small data set in the database , the same query never hangs when made through the libpq interface. I am puzzled by this difference in performance. Doesn't the psql client use the same libpq interface to send the queries to the database ? Any help on where to start would be appreciated.
ThanksAditya

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2013-09-07 14:46:36 Re: Difference in query performance when made from C/C++ client vs. psql client.
Previous Message Tom Lane 2013-09-06 14:02:52 Re: upgrading from postgresql 8.4 - postgis 1.3.6 to postgresql 9.2/postgis2.0