Skip to content

Use statement cache for copy_records_to_table introspection - #1360

Open
matemax wants to merge 2 commits into
MagicStack:masterfrom
matemax:fix-copy-records-regression
Open

matemax wants to merge 2 commits into
MagicStack:masterfrom
matemax:fix-copy-records-regression

Conversation

@matemax

@matemax matemax commented Sep 15, 2026

Copy link
Copy Markdown

Fixes: #1327

Commit 5b14653 (#1245) switched the introspection query in
copy_records_to_table() from _prepare(..., use_cache=True) to
prepare(), which never uses the statement cache. As a result every
call re-prepares SELECT ... LIMIT 1, adding a network round-trip per
COPY and a ~20% slowdown with non-trivial latency.

Restore the cache lookup. Named statements are still not used when
the statement cache is disabled, since _prepare() derives the name
from _stmt_cache_enabled.

@elprans elprans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

Regression in copy records performance between 0.30.0 and 0.31.0

2 participants