Difference in query performance when made from C/C++ client vs. psql client. - Mailing list pgsql-novice

From Aditya Rastogi
Subject Difference in query performance when made from C/C++ client vs. psql client.
Date
Msg-id BAY176-W3C969C1105340CF81826BC53D0@phx.gbl
Whole thread Raw
Responses Re: Difference in query performance when made from C/C++ client vs. psql client.  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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.

Thanks
Aditya 

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: upgrading from postgresql 8.4 - postgis 1.3.6 to postgresql 9.2/postgis2.0
Next
From: Tom Lane
Date:
Subject: Re: Difference in query performance when made from C/C++ client vs. psql client.