Re-index the events table with a combined topic/contract and ID#510
Merged
Re-index the events table with a combined topic/contract and ID#510
Conversation
Contributor
In thinking about this more I'm not incredibly concerned about this. In general, I think we may (debatably) want to limit any long-running/blocking migrations like index creations to major releases boundaries. But people that deploy RPC (or anything captive-core) should already have deployment architectures that are tolerant of downtime on upgrade, because captive-core's restart time is not instant. Given that, I think anything on the order of minutes is probably tolerable, so 🤞 |
ad1cb06 to
5cf69d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Replaces the existing indices on the
eventstable with one built on the first topic AND id.Why
Because the query always contains an
ORDER BY id ASCclause, the index ontopic1can't be utilized properly: it results in a full scan because sorting is necessary after the lookup. You can see this in the query planner:vs. a string-based search which can leverage the
idindex:Known limitations
There are ~67mm events in a week-long pubnet deployment, so we need to time this migration on the development cluster to add accurate release notes and operator expectations.
Maybe there's a way to change the query itself to use the indices properly?