Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why remove the prepared statements from cache? #391

Open
domoritz opened this issue Nov 6, 2024 · 1 comment
Open

Why remove the prepared statements from cache? #391

domoritz opened this issue Nov 6, 2024 · 1 comment

Comments

@domoritz
Copy link

domoritz commented Nov 6, 2024

Maybe I am misunderstanding the logic here but I wonder why duckdb removes the statement from the cache instead of just getting it? I would expect a call to https://paritytech.github.io/try-runtime-cli/hashlink/lru_cache/struct.LruCache.html#method.get.

https://github.com/duckdb/duckdb-rs/blame/2bd811e7b1b7398c4f461de4de263e629572dc90/crates/duckdb/src/cache.rs#L142

@sourcefrog
Copy link

I didn't write this code but from 80f6f90 it looks like the idea is that the statement is mutable while it's in use, perhaps at the DuckDB level. When you get the statement from the cache, the caller gets effectively exclusive use of it. But when the CachedStatement is dropped, it automatically puts itself back into the cache.

It seems a little strange compared to e.g. cloning when things are taken from the cache, or just keeping only immutable representations in the cache. But probably the C API constrains how things can be done.

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

No branches or pull requests

2 participants