Reduce queries for published graphs when indexing #11513
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
Description of Change
Before, when indexing resources there were 2 queries per graph to get the published graph in the active language. One for the GraphXPublishedGraph row, one for the PublishedGraph row. This was then cached in memory, persisting either for a short period (on the CLI) or potentially forever for server-side operations, which could lead to retrieving stale data.
Now, these are prefetched during
optimize_resource_iteration
, so that it takes 2 queries total per chunk, no matter how many graphs are involved. A typical chunk size is 500 (2000 // 8), so if two adjacent chunks each contain 500 resources of the same graph, then this might slightly increase queries, because we are no longer perpetually caching, but with a benefit of less memory overhead and better correctness for server-side operations--but in all other cases this should reduce queries by avoiding repetitive published graph queries.Checklist
Ticket Background