-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: FK validations are slow #15157
Comments
@mattiasmak lets discuss the latency issues you are observing here. Thanks! |
We'd appreciate it if you attach the kinds of SQL requests you are running against this cluster, and also include the schema for the venue and device tables. Thanks |
These two queries are executed:
|
I have a few ideas here, ordered roughly from simpler to more challenging.
|
@jordanlewis Can you explain how FK lookups are currently done? Is no batching being done? |
There is no batching done at all for FK lookups. On insert, a single scan is sent sequentially for each of the Proposal 1 above involves batching the |
Well, to be more precise, proposal 3 has at most |
Yowzer, that's not good. |
I expect helper-lifetime caching to be a big win too and am excited to see where that goes if you try it. Note that even in the statement-lifetime cache, you might want to disable caching for self-referential FKs: unlike cross-table FKs, a self-FK could easily be writing to the checked rows in the same statement, so just like the txn-lifetime cache, you'd have add some substantial invalidation complexity. |
#18730 helped with this, but there's still more work to be done. @BramGruneir would you be interested in looking at this after you're done with the FK actions work? |
FWIW @nvanbenschoten had proposed a KV-level key existence cache which would help here too. |
@BramGruneir @jordanlewis Disregard request for description; didn't see this was written up in 1.0. |
@RaduBerinde think we can close this now? Is it providing any value? |
FKs have been rewritten recently. Feel free to open a new issue if you still are having problems, thanks! |
As part of #15026 a complex schema with FKs
reveal high latency on SQL queries.
The text was updated successfully, but these errors were encountered: