Skip to content

Narrow the COPY text match to statement starts #27

Open

Description

@okomarov

#21 recognises a COPY from simple-protocol query text with \bcopy\b, so nothing is pipelined behind it. The word also matches in comments (-- copy), string literals ('Copy of report'), quoted identifiers ("copy") and dollar-quoted bodies. A false positive only stops pipelining behind that query, but a burst made entirely of such queries measured p50/p95/p99 of 724/1373/1429 ms against about 72/80/103 ms at max: 1 (190/350/380 against 31/76/80 at max: 4, 20 ms round trip).

Possible improvements:

  • Match copy only at a statement start: the beginning of the text, after ;, or after leading comments and whitespace. Still safe, since COPY to or from the client is always a top-level statement.
  • Also treat START_REPLICATION (CopyBoth) as a barrier, and make accepting() false while a COPY stream is open.

Activity

  1. okomarov commented on Oct 11, 2026

    @okomarov
    Author

    Since 4.4.0 sends savepoint statements through the simple protocol (#30), a savepoint name containing the word copy (for example sql.savepoint("my-copy", …)) also matches and sets the COPY barrier: statements behind it wait one round trip. Results stay correct. Narrowing the match to statement starts would cover it too.

  2. moved this to Later in Roadmapon Oct 15, 2026
  3. added
    area: protocol
    bug
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: protocolbug

    Type

    No type

    Projects

    • Status
      Later

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions