jackc / jackc/pgx

Lazy transaction BEGIN

Open
#1,667 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

**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.Exec`ing `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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Conn.BeginTx and the Conn.Exec path that sends BEGIN. Compare the proposed lazy behavior with Pipeline/Batch and the existing Tx API. Done means BEGIN is sent with the first transaction query, or its result is deferred until then, while preserving the Tx API.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.