-
Notifications
You must be signed in to change notification settings - Fork 409
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
Implement persistent query cache for single queries #6881
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Should we just cache the text and not bother with functions? |
Another option might be to actually generate composite types for everything returned by queries. That seems kind of miserable, though. |
This comment was marked as resolved.
This comment was marked as resolved.
Hm, though the |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
ef9ce43
to
9580dee
Compare
Let's make sure to document this |
62d1cf1
to
4d46f95
Compare
It seems like we don't populate the cache in transactions, which means that the test suite is not going to be exercising the cache very much. |
Yeah, that seemed to be the case for some time already, I do have a TODO in the pre-RFC to add the in-transaction cache back. |
1153a39
to
8aa86aa
Compare
Some other things we might want:
Thing two is mostly something that I need, but arguably these two things can be the same, and the way to "disable recompilation" is just to clear the cache first. |
sql_res = pg_compiler.compile_ir_to_sql_tree( | ||
ir, | ||
expected_cardinality_one=ctx.expected_cardinality_one, | ||
output_format=_convert_format(ctx.output_format), | ||
backend_runtime_params=ctx.backend_runtime_params, | ||
expand_inhviews=options.expand_inhviews, | ||
detach_params=bool(use_persistent_cache and debug.flags.func_cache), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need the bool
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right if we can let mypy think Flag
is a bool
:
edb/server/compiler/compiler.py:1854:23: error: Argument "detach_params" to "compile_ir_to_sql_tree" has incompatible type "Flag | bool"; expected "bool" [arg-type]
edb/server/dbview/dbview.pyx
Outdated
if keys: | ||
self.tenant.create_task( | ||
self.tenant.evict_query_cache(self.name, keys), | ||
interruptable=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? (Genuinely I am not sure.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, script cache! Now fixed and I'll add a test to cover this branch.
Is this reliable, or do we need to properly retry??
* Apply review suggestions * More comments and code style * Fix eviction on scripts * Fix missing signal in clear_cache_keys() * Recompiled queries are persited in batches * Fix bug that recompile didn't work
COMMIT may also contain user_schema, so we know DDL was in the tx
5a31914
to
1769098
Compare
QueryUnit
in consideration of the future per-statement script cachepickle
to serializeQueryUnit
, prefixed with a one-byte version numberedgedb._query_cache
table serialized, restored when firstly introspecting the database/branchEDGEDB_DEBUG_FUNC_CACHE=1
creation_time
for a less-brain-split distributed LRUFunction TODOs:
record[]