perf(db): fix #245 add brin index on contract_events and endpoint - #778
Open
fhayvy wants to merge 2 commits into
Open
perf(db): fix #245 add brin index on contract_events and endpoint#778fhayvy wants to merge 2 commits into
fhayvy wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
@fhayvy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #245
Addes a BRIN (Block Range INdex) index on the
contract_eventstable'screated_atcolumn, and implementing a corresponding Express REST API endpointGET /importers/admin/eventsto query events in a time range with pagination.Rationale & Flow:
contract_events.created_atusing BRIN withpages_per_range = 32. Since event data is written in roughly chronological order, the values ofcreated_atare highly correlated with their physical location in the table. BRIN indices are extremely small (~1:800 or 99.8% smaller than a B-Tree index), saving valuable memory and disk space under high ingestion volumes.GET /importers/admin/eventswhich acceptsfrom(ISO 8601),to(ISO 8601),limit(max 500), andoffsetparameters, validating them using Zod. The endpoint is secured so only users with thesurety_adminrole can access it, querying database events filtered by the date range using the BRIN index.oracle-event-listener.ts) to ensure a completely clean build.