Skip to content

Commit 8651d28

Browse files
authored
chore(db): Add index for finalization (#4420)
## What ❔ Now usage of finality status is increased we can utilize an index ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [ ] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --------- Signed-off-by: Danil <[email protected]>
1 parent 7edd4ea commit 8651d28

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DROP INDEX IF EXIST eth_txs_history_finalized;
2+
DROP INDEX IF EXIST eth_txs_history_non_finalized;
3+
DROP INDEX IF EXIST eth_txs_non_gateway_index;
4+
DROP INDEX IF EXIST eth_txs_gateway_index;
5+
DROP INDEX IF EXIST miniblocks_precommit_txs;
6+
CREATE INDEX IF NOT EXISTS eth_precommit_tx_id_miniblocks ON miniblocks (eth_precommit_tx_id);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DROP INDEX IF EXISTS eth_precommit_tx_id_miniblocks;
2+
3+
CREATE INDEX IF NOT EXISTS eth_txs_history_finalized ON eth_txs_history ( eth_tx_id ) WHERE (finality_status = 'finalized');
4+
CREATE INDEX IF NOT EXISTS eth_txs_history_non_finalized ON eth_txs_history ( id ) WHERE (finality_status != 'finalized');
5+
CREATE INDEX IF NOT EXISTS eth_txs_non_gateway_index ON eth_txs ( from_addr, confirmed_eth_tx_history_id ) WHERE ( is_gateway = false and from_addr is not null);
6+
CREATE INDEX IF NOT EXISTS eth_txs_gateway_index ON eth_txs ( from_addr, confirmed_eth_tx_history_id ) WHERE ( is_gateway = true and from_addr is not null);
7+
CREATE INDEX IF NOT EXISTS miniblocks_precommit_txs ON miniblocks ( eth_precommit_tx_id, number );

0 commit comments

Comments
 (0)