Skip to content

Commit

Permalink
fix(db): Optimize get_l2_blocks_to_execute_for_l1_batch (#2199)
Browse files Browse the repository at this point in the history
## What ❔

Optimize `get_l2_blocks_to_execute_for_l1_batch`

## Why ❔

`transactions.l1_batch_number` is not indexed

## 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 `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
  • Loading branch information
perekopskiy authored Jun 11, 2024
1 parent 4c18755 commit 06ec5f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion core/lib/dal/src/transactions_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,21 @@ impl TransactionsDal<'_, '_> {
FROM
transactions
WHERE
l1_batch_number = $1
miniblock_number BETWEEN (
SELECT
MIN(number)
FROM
miniblocks
WHERE
miniblocks.l1_batch_number = $1
) AND (
SELECT
MAX(number)
FROM
miniblocks
WHERE
miniblocks.l1_batch_number = $1
)
ORDER BY
miniblock_number,
index_in_block
Expand Down

0 comments on commit 06ec5f3

Please sign in to comment.