Skip to content

Add wait events for COPY file/program operations#11

Closed
NikolayS wants to merge 0 commit intoclaude/review-postgres-discussions-n0hWBfrom
claude/copy-wait-events-n0hWB
Closed

Add wait events for COPY file/program operations#11
NikolayS wants to merge 0 commit intoclaude/review-postgres-discussions-n0hWBfrom
claude/copy-wait-events-n0hWB

Conversation

@NikolayS
Copy link
Copy Markdown
Owner

@NikolayS NikolayS commented Jan 7, 2026

Summary

COPY operations previously showed wait_event = NULL when blocking on file/program I/O, making it impossible to diagnose performance issues during data loading, ETL operations, or pg_dump/pg_restore.

This patch adds two new IO wait events:

  • COPY_DATA_READ: When COPY FROM blocks reading from file or program
  • COPY_DATA_WRITE: When COPY TO blocks writing to file or program

Coverage

COPY Variant Wait Event
COPY FROM file COPY_DATA_READ
COPY TO file COPY_DATA_WRITE
COPY FROM PROGRAM COPY_DATA_READ
COPY TO PROGRAM COPY_DATA_WRITE
COPY FROM/TO STDIN/STDOUT CLIENT_READ/WRITE (existing)

Note: STDIN/STDOUT already have coverage via Client/ClientRead and Client/ClientWrite events at the protocol layer.

Use Cases

  • Diagnose slow pg_dump/pg_restore operations
  • Identify storage I/O bottlenecks during bulk loads
  • Analyze pipe buffer congestion in ETL pipelines
  • ASH (Active Session History) analysis of COPY operations

Changes

  • src/backend/commands/copyfromparse.c: Wrap fread() with wait events
  • src/backend/commands/copyto.c: Wrap fwrite() with wait events
  • src/backend/utils/activity/wait_event_names.txt: Add event definitions

@NikolayS NikolayS changed the base branch from master to claude/review-postgres-discussions-n0hWB January 7, 2026 23:28
@NikolayS NikolayS force-pushed the claude/review-postgres-discussions-n0hWB branch from fe60593 to e0fe9e6 Compare January 8, 2026 21:16
@NikolayS NikolayS force-pushed the claude/copy-wait-events-n0hWB branch 4 times, most recently from fd54927 to 54a3b83 Compare January 8, 2026 21:51
@NikolayS NikolayS force-pushed the claude/review-postgres-discussions-n0hWB branch from e0fe9e6 to 5c59925 Compare April 22, 2026 17:38
@NikolayS NikolayS closed this Apr 22, 2026
@NikolayS NikolayS force-pushed the claude/copy-wait-events-n0hWB branch from 54a3b83 to 5c59925 Compare April 22, 2026 17:38
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.

1 participant