-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: index on
principal_stx_txs
table for faster `/v1/address/{addr…
…}/transactions` lookups (#2059) * fix: index on `principal_stx_txs` table for faster `v1/address/{addr}/transactions` lookups * test: fix tx_index ordering in test
- Loading branch information
Showing
2 changed files
with
70 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */ | ||
exports.up = pgm => { | ||
pgm.createIndex( | ||
'principal_stx_txs', | ||
[ | ||
'principal', | ||
{ name: 'block_height', order: 'DESC' }, | ||
{ name: 'microblock_sequence', order: 'DESC' }, | ||
{ name: 'tx_index', order: 'DESC' }], | ||
{ | ||
name: 'idx_principal_stx_txs_optimized', | ||
where: 'canonical = TRUE AND microblock_canonical = TRUE', | ||
} | ||
); | ||
}; | ||
|
||
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */ | ||
exports.down = pgm => { | ||
pgm.dropIndex('principal_stx_txs', ['principal', 'block_height', 'microblock_sequence', 'tx_index'], { | ||
name: 'idx_principal_stx_txs_optimized', | ||
}); | ||
}; |
This file contains 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