Skip to content

pg-native: read all the values of a result in one call - #3814

Open
nigrosimone wants to merge 1 commit into
brianc:masterfrom
nigrosimone:pg-native-getvalues
Open

nigrosimone wants to merge 1 commit into
brianc:masterfrom
nigrosimone:pg-native-getvalues

Conversation

@nigrosimone

Copy link
Copy Markdown
Contributor

pg-native builds a result with one native call per value (getvalue, plus getisnull when the value is ''). On large results this is the main cost, and it is why pg-native is slower than pg on 100 and 500 rows in the postgres-benchmarks, more on some CPUs than others.

When libpq has getvalues (brianc/node-libpq#144) all the values are read in one call. With an older libpq nothing changes. In a microbenchmark building the result takes 52-60% less time for 100 and 500 rows, about 10% less for 1 row.

Test added in test/build-result.js with a fake libpq result, so it runs without the new libpq: it checks both paths, and fails without the fix.

@nigrosimone
nigrosimone marked this pull request as ready for review October 11, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant