Skip to content

Commit

Permalink
use partition ids with lightweight delete
Browse files Browse the repository at this point in the history
  • Loading branch information
iuwqyir committed Dec 13, 2024
1 parent 996d70b commit 7c89ae1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/storage/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,14 +1004,14 @@ func (c *ClickHouseConnector) DeleteBlockData(chainId *big.Int, blockNumbers []*
}

func (c *ClickHouseConnector) deleteBatch(chainId *big.Int, blockNumbers []*big.Int, table string, blockNumberColumn string) error {
query := fmt.Sprintf("DELETE FROM %s.%s WHERE chain_id = ? AND %s IN (?)", c.cfg.Database, table, blockNumberColumn)
query := fmt.Sprintf("DELETE FROM %s.%s WHERE _partition_id = ? AND chain_id = ? AND %s IN (?)", c.cfg.Database, table, blockNumberColumn)

blockNumbersStr := make([]string, len(blockNumbers))
for i, bn := range blockNumbers {
blockNumbersStr[i] = bn.String()
}

err := c.conn.Exec(context.Background(), query, chainId, blockNumbersStr)
err := c.conn.Exec(context.Background(), query, chainId, chainId, blockNumbersStr)
if err != nil {
return fmt.Errorf("error deleting from %s: %w", table, err)
}
Expand Down

0 comments on commit 7c89ae1

Please sign in to comment.