-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
sql: turn on query cache #34454
sql: turn on query cache #34454
Conversation
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.
It does seem like there may be some kind of issue preventing us from getting close to prepare-once. I agree that we should enable for the alpha and then try to figure out what's going on.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @andy-kimball, @justinj, and @rytaft)
bors r+ |
Build failed |
bors r+ |
I fixed a race condition in the query cache code. The @RaduBerinde, I put a TODO in the code for you to see if there's a better fix. For now, I made a copy of the |
bors r- |
Canceled |
bors r+ |
Merge conflict (retrying...) |
Build failed |
8907c7d
to
6ed8655
Compare
Release note (performance improvement): A query plan cache saves a portion of the planning time for frequent queries.
The PreparedMetadata was being put into the cache, but then the InferredTypes field was being set after that by execPrepare. The fix is to make a copy of PreparedMetadata before entering it into the cache. Release note: None
6ed8655
to
317a77d
Compare
bors r+ |
34454: sql: turn on query cache r=andy-kimball a=RaduBerinde Release note (performance improvement): A query plan cache saves a portion of the planning time for frequent queries. Some benchmarks with KV: https://docs.google.com/spreadsheets/d/1n818OsKTWsatbpXo5ddOJ53mL4hY-JhNJEuIlytilLc/edit#gid=0 While there is some improvement, the implicit prepare case is still nowhere close to prepare-once; I plan to benchmark and do more work on the prepare path. I think it's a good idea to enable the cache now though, so we get more time to weed out any problems. Co-authored-by: Radu Berinde <radu@cockroachlabs.com> Co-authored-by: Andrew Kimball <andyk@cockroachlabs.com>
Build failed |
Thanks, LGTM! I will look at moving that InferredTypes code earlier, before we add to the cache (or otherwise remove it from PrepareMetadata). |
Last run was a flake in TestDockerCLI, trying again. bors r+ |
Build failed |
Ah.. looks like we have to invalidate a cached memo if SafeUpdates changes. I guess I didn't run into that because updates were not planned with opt (I assume they are now?) |
Alternatively we could move that check to execution - seems like that's where it belongs conceptually. |
Do not use cached memo if the SafeUpdates setting does not match. Release note: None
I added a check for it. |
bors r+ |
34454: sql: turn on query cache r=andy-kimball a=RaduBerinde Release note (performance improvement): A query plan cache saves a portion of the planning time for frequent queries. Some benchmarks with KV: https://docs.google.com/spreadsheets/d/1n818OsKTWsatbpXo5ddOJ53mL4hY-JhNJEuIlytilLc/edit#gid=0 While there is some improvement, the implicit prepare case is still nowhere close to prepare-once; I plan to benchmark and do more work on the prepare path. I think it's a good idea to enable the cache now though, so we get more time to weed out any problems. Co-authored-by: Radu Berinde <radu@cockroachlabs.com> Co-authored-by: Andrew Kimball <andyk@cockroachlabs.com>
Build succeeded |
Thank you, looks great! |
Release note (performance improvement): A query plan cache saves a
portion of the planning time for frequent queries.
Some benchmarks with KV: https://docs.google.com/spreadsheets/d/1n818OsKTWsatbpXo5ddOJ53mL4hY-JhNJEuIlytilLc/edit#gid=0
While there is some improvement, the implicit prepare case is still nowhere close to prepare-once; I plan to benchmark and do more work on the prepare path. I think it's a good idea to enable the cache now though, so we get more time to weed out any problems.