Skip to content

Reduce PostgreSQL TCP buffering and extended-query cleanup round trips - #477

Open
marcelomendoncasoares wants to merge 4 commits into
isoos:masterfrom
marcelomendoncasoares:perf/query-wire-round-trips
Open

marcelomendoncasoares wants to merge 4 commits into
isoos:masterfrom
marcelomendoncasoares:perf/query-wire-round-trips

Conversation

@marcelomendoncasoares

@marcelomendoncasoares marcelomendoncasoares commented Oct 27, 2026 •

Copy link
Copy Markdown

TCP connections now enable TCP_NODELAY before PostgreSQL startup and TLS negotiation when supported. Unix sockets skip the option, and failed socket setup closes the unowned socket.

Extended queries now send Close(portal) after Execute and before the same Sync. This removes the separate cleanup exchange inside transactions, including cleanup errors after already-queued queries commit or roll back. Queries still wait for ReadyForQuery and cancellation drain; named statement disposal, TLS policy, explicit transaction boundaries and row locks remain intact.

Validation covers exact message order, zero/many rows, named statement reuse, Parse/Bind/Execute errors, callback/SQL-error rollback, cancellation and connection reuse, stream subscription cancellation, row locks through commit/rollback, server-side COPY, binary/text logical replication, and real Unix/TLS transport. Linux getsockopt confirms TCP_NODELAY before SSLRequest, with base controls failing both new optimization assertions.

@marcelomendoncasoares

Copy link
Copy Markdown
Author

Sorry for this PR out of the blue. I'm doing some performance improvement tests on serverpod_offline_sync for usage with Serverpod Cloud and the agent went a bit haywire... I'll still review this PR manually and get it into proper shape if proposing this change is really justified.

@marcelomendoncasoares
marcelomendoncasoares marked this pull request as ready for review October 29, 2026 23:24
@marcelomendoncasoares

Copy link
Copy Markdown
Author

Thanks for fixing the CHANGELOG here, @isoos! I have manually reviewed and only had to correct one small doc. Ready for your review when you have the time!

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