Commit 5abcb28
committed
Cache C-API prepared statements for repeated parameterized execute() calls
The pybind path was already patched with _get_or_prepare_pybind_statement
to reuse prepared statements for repeated parameterized execute()
calls, preventing unbounded memory growth (RSS raising).
The C-API execute() path had the same bug: every parameterized
execute() with a string query created a new PreparedStatement via
self._prepare(), which called self._connection.prepare() on the
C-API module — never reusing previously prepared statements.
Add _get_or_prepare_capi_statement() that caches PreparedStatement
objects keyed by the normalized query string in the same
_pybind_implicit_prepared_cache dict (already cleared on close).
The else branch now delegates to this cache instead of calling
self._prepare() directly.1 parent 7d514fa commit 5abcb28
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
482 | 494 | | |
483 | 495 | | |
484 | 496 | | |
| |||
582 | 594 | | |
583 | 595 | | |
584 | 596 | | |
585 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
586 | 600 | | |
587 | 601 | | |
588 | 602 | | |
| |||
0 commit comments