Skip to content

Commit

Permalink
fix(pruning): query optimization (#1904)
Browse files Browse the repository at this point in the history
Signed-off-by: tomg10 <[email protected]>
  • Loading branch information
tomg10 authored May 10, 2024
1 parent 086f768 commit 9154390
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.

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

This file was deleted.

18 changes: 9 additions & 9 deletions core/lib/dal/src/pruning_dal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,17 @@ impl PruningDal<'_, '_> {
) -> DalResult<u64> {
let execution_result = sqlx::query!(
r#"
DELETE FROM storage_logs USING (
SELECT
*
FROM
storage_logs
WHERE
miniblock_number BETWEEN $1 AND $2
) AS batches_to_prune
DELETE FROM storage_logs
WHERE
storage_logs.miniblock_number < $1
AND batches_to_prune.hashed_key = storage_logs.hashed_key
AND hashed_key IN (
SELECT
hashed_key
FROM
storage_logs
WHERE
miniblock_number BETWEEN $1 AND $2
)
"#,
i64::from(l2_blocks_to_prune.start().0),
i64::from(l2_blocks_to_prune.end().0)
Expand Down

0 comments on commit 9154390

Please sign in to comment.