Skip to content

Commit

Permalink
fix: index on principal_stx_txs table for faster `v1/address/{addr}…
Browse files Browse the repository at this point in the history
…/transactions` lookups
  • Loading branch information
zone117x committed Aug 21, 2024
1 parent 40dbcc6 commit 6fbf53e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions migrations/1724229744369_principal_stx_txs_idx.js
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',
});
};

0 comments on commit 6fbf53e

Please sign in to comment.