Skip to content

Conversation

@levkk
Copy link
Collaborator

@levkk levkk commented Jan 15, 2026

When prepared statements were frequently evicted, the algorithm that was calculating the memory usage for the prepared statement data structure iterated over every single statement in the cache. This was effectively O(n^2) in the worst case, and it was burning CPU to provide only an approximation.

This change uses a simpler algorithm to calculate memory usage that doesn't have to walk the entire data structure.

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/frontend/prepared_statements/mod.rs 89.28% 3 Missing ⚠️
pgdog/src/backend/prepared_statements.rs 80.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@levkk levkk merged commit 32b3942 into main Jan 15, 2026
8 checks passed
@levkk levkk deleted the levkk-fix-prep-stmt-cpu-churn branch January 15, 2026 20: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.

2 participants