#1667·pgx

Lazy transaction BEGIN

Author: redbaronCreated Jun 30, 2023Updated Sep 8, 2026

Is your feature request related to a problem? Please describe. On a high latency connections every additional roundtrip between client and server is undesirable. Conn.BeginTx starts transaction by Conn.Execing BEGIN command, which internally waits for result. This wait time is a wasteful and app can't do much about it.

Describe the solution you'd like Delay BEGIN and sendit it together with first query in transaction, essentially making it lazy. Alternatively utilize Pipeline/Batch to send it in BeginTx, but don't wait for it's result until first query in transaction is issued.

Describe alternatives you've considered App can chose to use Batch and manually roll BEGIN/COMMIT into the batch, but then it loses convenience of Tx API.