fix(indexer): use indexed exact-match participant columns instead of ILIKE on JSON - #921
Open
sasasamaes wants to merge 2 commits into
Open
fix(indexer): use indexed exact-match participant columns instead of ILIKE on JSON#921sasasamaes wants to merge 2 commits into
sasasamaes wants to merge 2 commits into
Conversation
🤖 Greptile AI Code ReviewGreptile will automatically review this PR (3 file(s) changed). Review gates:
|
…ILIKE on JSON (FinChippay#889) Participant queries (queryEventsByPublicKey, queryEventsByType, getEventStats) previously scanned the serialized payload with payload::text ILIKE '%<publicKey>%' — a full-table scan that also produced false matches when the key appeared in unrelated fields (e.g. a memo). - Rewrite all three query helpers to match exactly on from_addr/to_addr - Add migration 028: composite index idx_events_participants (from_addr, to_addr) for fast lookups (cross-dialect) - Keep the in-memory fallback store in sync (exact column match) - Add 13 tests covering exact-participant filtering and rejection of memo substring false positives Closes FinChippay#889
sasasamaes
force-pushed
the
fix/indexer-column-queries
branch
from
August 26, 2026 03:29
e84d746 to
5cdf7ec
Compare
GitHub Actions does not allow the `secrets` context inside step-level `if:` conditionals, which made contract-type-check.yml fail workflow validation. Expose TESTNET_CONTRACT_ID as a job-level env var and gate the steps on `env.*` instead.
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 #889
Summary
Participant queries in
backend/src/services/eventIndexer.js(queryEventsByPublicKey,queryEventsByType,getEventStats) previously usedpayload::text ILIKE '%<publicKey>%'— a full-text substring scan over the entirecontract_eventstable. This caused:The table already stores parsed
from_addr/to_addrcolumns (populated on insert viaeventParser.js), but the query helpers never used them.Changes
from_addr = $1 OR to_addr = $2028_events_participants_index.js: cross-dialect composite indexidx_events_participants (from_addr, to_addr)(usesCREATE INDEX IF NOT EXISTS, hasdown()rollback per CONTRIBUTING.md)_seedForTesthelper to seed events into the in-memory store for testsTests
New suite
backend/__tests__/eventIndexer-column-queries.test.js(13 tests):queryEventsByPublicKey,queryEventsByType)getEventStatscounts only true participants and does not inflate from memo matchesAll 13 new tests pass; existing 15 integration-eventIndexer tests still pass;
eslint src/**/*.jsreports no issues in changed files.Acceptance Criteria