Skip to content

feat: add tx seq index#128

Merged
songwongtp merged 2 commits intomainfrom
feat/add-tx-seq-index
Apr 8, 2026
Merged

feat: add tx seq index#128
songwongtp merged 2 commits intomainfrom
feat/add-tx-seq-index

Conversation

@songwongtp
Copy link
Copy Markdown
Collaborator

@songwongtp songwongtp commented Apr 8, 2026

Summary by CodeRabbit

  • Chores
    • Database indexing improvements: Added two concurrent indexes on transaction sequence columns to optimize query performance and reduce lookup times for sequence-based operations.
    • Schema metadata updated to ensure the new indexes are reflected in application data mappings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34c167a5-0825-4f26-a2ce-d9b69a6fd348

📥 Commits

Reviewing files that changed from the base of the PR and between fac76c8 and f837fc9.

⛔ Files ignored due to path filters (1)
  • orm/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • orm/migrations/20260408163700_add_tx_accounts_sequence_index.sql
  • types/table.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • orm/migrations/20260408163700_add_tx_accounts_sequence_index.sql

Walkthrough

Adds concurrent PostgreSQL indexes on the sequence column for tx_accounts and tx_msg_types via a migration and annotates the corresponding GORM struct fields with named index tags.

Changes

Cohort / File(s) Summary
Migration
orm/migrations/20260408163700_add_tx_accounts_sequence_index.sql
Adds CREATE INDEX CONCURRENTLY statements to create idx_tx_accounts_sequence on public.tx_accounts(sequence) and idx_tx_msg_types_sequence on public.tx_msg_types(sequence).
ORM struct tags
types/table.go
Updates CollectedTxAccount.Sequence and CollectedTxMsgType.Sequence GORM tags to include named indexes: index:idx_tx_accounts_sequence and index:idx_tx_msg_types_sequence (fields remain bigint;primaryKey).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A little rabbit hops with glee,
Indexes planted, two by three,
Migration sows them, tags agree,
Leaves the queries light and free,
Nibble on speed — a joyous spree! 🐇✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add tx seq index' accurately describes the main change: adding sequence indexes to transaction-related tables through GORM struct tag modifications and a database migration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-tx-seq-index

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
types/table.go (1)

61-65: Consider specifying an explicit index name for clarity.

The unnamed index tag will generate idx_tx_accounts_sequence by default, which matches the Atlas migration. For better maintainability and explicit documentation, consider naming it:

-	Sequence  int64 `gorm:"type:bigint;primaryKey;index"`
+	Sequence  int64 `gorm:"type:bigint;primaryKey;index:idx_tx_accounts_sequence"`

Also note that similar join tables (CollectedTxNft, CollectedTxMsgType, CollectedTxTypeTag, CollectedEvmTxAccount, CollectedEvmInternalTxAccount) don't have an index on their Sequence fields. If this index is needed for query performance on tx_accounts, similar indexes may be beneficial for those tables as well—worth verifying the query patterns.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@types/table.go` around lines 61 - 65, The CollectedTxAccount struct's
Sequence field uses an unnamed GORM index which implicitly creates
idx_tx_accounts_sequence; update the struct tag for CollectedTxAccount.Sequence
to provide an explicit index name (e.g.,
`index:idx_collected_tx_account_sequence`) so the generated migration and code
are clear and consistent, and then review the related structs CollectedTxNft,
CollectedTxMsgType, CollectedTxTypeTag, CollectedEvmTxAccount, and
CollectedEvmInternalTxAccount to determine if a similarly named Sequence index
should be added to those types for parity and query-performance consistency;
adjust tags on the identified structs accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@types/table.go`:
- Around line 61-65: The CollectedTxAccount struct's Sequence field uses an
unnamed GORM index which implicitly creates idx_tx_accounts_sequence; update the
struct tag for CollectedTxAccount.Sequence to provide an explicit index name
(e.g., `index:idx_collected_tx_account_sequence`) so the generated migration and
code are clear and consistent, and then review the related structs
CollectedTxNft, CollectedTxMsgType, CollectedTxTypeTag, CollectedEvmTxAccount,
and CollectedEvmInternalTxAccount to determine if a similarly named Sequence
index should be added to those types for parity and query-performance
consistency; adjust tags on the identified structs accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0e45f61-abcd-4675-91d8-ab838db2e867

📥 Commits

Reviewing files that changed from the base of the PR and between 09662eb and fac76c8.

⛔ Files ignored due to path filters (1)
  • orm/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • orm/migrations/20260408163700_add_tx_accounts_sequence_index.sql
  • types/table.go

@songwongtp songwongtp merged commit 9842269 into main Apr 8, 2026
6 checks passed
@songwongtp songwongtp deleted the feat/add-tx-seq-index branch April 8, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants