Skip to content

perf: remove superfluous flush message #2842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2022

Conversation

olavloite
Copy link
Contributor

node-postgres sends both a Flush and a Sync message at the end of an extended protocol query protocol session. This is not necessary, as Sync already implicitly includes Flush. Flush will cause the backend to flush its network buffers and return any pending responses to the client. Sync will do the same, but also commit the implicit transaction (if any) and the backend will respond with a ReadyForQuery message. Removing this extra step will save one network message for each extended query protocol session that is executed.

We noticed this behavior while testing the node-postgres driver with our proxy that allows Cloud Spanner to be used with PostgreSQL drivers.

@brianc
Copy link
Owner

brianc commented Oct 15, 2022

ohhh nice - less network traffic is good, right!? 😄 Thanks for the writeup. Normally I need tests for changes but this change is tested already but almost every integration test in the project so we're good there! (existing tests do have to pass though)

@brianc brianc merged commit 406f141 into brianc:master Oct 15, 2022
@olavloite olavloite deleted the remove-duplicate-flush branch October 16, 2022 10:04
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.

2 participants