From 7c89ae1e82bfcfea7b7b693aa499484df4304cc9 Mon Sep 17 00:00:00 2001 From: iuwqyir Date: Fri, 13 Dec 2024 15:53:34 +0200 Subject: [PATCH] use partition ids with lightweight delete --- internal/storage/clickhouse.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/storage/clickhouse.go b/internal/storage/clickhouse.go index 7248007..7c877ab 100644 --- a/internal/storage/clickhouse.go +++ b/internal/storage/clickhouse.go @@ -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) }