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

Reduce overhead of building foreign constraint graph #7581

Open
JelteF opened this issue Apr 15, 2024 · 1 comment
Open

Reduce overhead of building foreign constraint graph #7581

JelteF opened this issue Apr 15, 2024 · 1 comment

Comments

@JelteF
Copy link
Contributor

JelteF commented Apr 15, 2024

Currently on every foreign key change, each backend has to rebuild their foreign key graph. This can be quite some overhead when using schema based sharding with many tables and many constraints, because we do a sequence scan over pg_constraint.

Two ideas on how to improve this:

  1. Lazily build the parts of the graph that are needed. For schema based sharding it's expected that there are many small and completely disjoint graphs (one for each schema/colocation group). It does not make much sense to build all these little graphs, if you're only interested in the graph for a single schema.
  2. Don't invalidate the full graph on a foreign key change. I'm not sure if this is even really possible.
@JelteF
Copy link
Contributor Author

JelteF commented Apr 29, 2024

Another option could be to stop caching this graph and only get the information we need on the fly. But that would need some investigation into when we actually use this information and how expensive it is to get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant