Add more efficient functions to pqformat API.
Andres Freund <andres@anarazel.de>
Add more efficient functions to pqformat API. There's three prongs to achieve greater efficiency here: 1) Allow reusing a stringbuffer across pq_beginmessage/endmessage, with the new pq_beginmessage_reuse/endmessage_reuse. This can be beneficial both because it avoids allocating the initial buffer, and because it's more likely to already have an correctly sized buffer. 2) Replacing pq_sendint() with pq_sendint$width() inline functions. Previously unnecessary and unpredictable branches in pq_sendint() were needed. Additionally the replacement functions are implemented more efficiently. pq_sendint is now deprecated, a separate commit will convert all in-tree callers. 3) Add pq_writeint$width(), pq_writestring(). These rely on sufficient space in the StringInfo's buffer, avoiding individual space checks & potential individual resizing. To allow this to be used for strings, expose mbutil.c's MAX_CONVERSION_GROWTH. Followup commits will make use of these facilities. Author: Andres Freund Discussion: https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/libpq/pqformat.c | modified | +33 −55 |
| src/backend/utils/mb/mbutils.c | modified | +0 −11 |
| src/include/libpq/pqformat.h | modified | +164 −4 |
| src/include/mb/pg_wchar.h | modified | +11 −0 |
Discussion
- SendRowDescriptionMessage() is slow for queries with a lot of columns 29 messages · 2017-09-14 → 2017-10-11