From: | James Duong <jamesd(at)simba(dot)com> |
---|---|
To: | "pgsql-interfaces(at)postgresql(dot)org" <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | libpq single-row mode performance |
Date: | 2014-07-03 01:05:32 |
Message-ID: | 59b2f266559a4a46835d2add16d80c39@DM2PR04MB589.namprd04.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi,
I'm writing an app on top of libpq. To avoid running out of memory I'm using the single-row mode, but am finding the overhead in using this quite significant.
What I see is that ~60% of my application's run time when retrieving data is spent in calls to either PQgetResult() and PQclear(). I've added a switch in my app to turn off single-row mode and the performance roughly doubles.
Would it be possible to optimize the single-row mode? For example, add an API call PQnextRow(PGConn*), which is only usable in single-row mode and will just update the existing result with the contents of the next row? This would let us avoid to overhead of:
1. Malloc'ing a PGResult and initializing its defaults.
2. Copying the column metadata to the new results.
3. Possibly we can avoid malloc'ing cell data if the next row has cells the same size or smaller than a previous row, though I'm not sure of the internals here.
4. Release memory with PQclear().
James Duong | Senior Computer Scientist | Simba Technologies Inc.
Tel +1.604.633.0008 ext. 120 | Fax +1.604.633.0004 | jamesd(at)simba(dot)com<mailto:jamesd(at)simba(dot)com>
938 West 8th Avenue | Vancouver, BC | Canada | V5Z 1E5
The Data Access and Analytics Experts | www.simba.com<http://www.simba.com/>
[Description: Description: Description: Description: twitter]<http://twitter.com/#!/simbatech> [Description: Description: Description: Description: youtube] <http://www.youtube.com/user/SimbaTechnologies> [Description: Description: Description: Description: linkedin] <http://ca.linkedin.com/in/simbatechnologies> [Description: Description: Description: Description: facebook] <http://www.facebook.com/pages/Simba-Technologies-Inc/163133087033256> [Description: Description: Description: Description: google-plus] <https://plus.google.com/116908198145591559055/posts> [Description: Description: Description: Description: typepad] <http://blogs.simba.com/>
This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Thank you.
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Golub | 2014-07-03 12:27:49 | Re: libpq single-row mode performance |
Previous Message | James Duong | 2014-06-28 03:25:30 | libpq batched parameterized query execution |