Skip to content

Commit 7aeffe8

Browse files
authored
use lightweight deletes (#120)
### TL;DR Updated the DELETE query syntax in ClickHouse to use lightweight DELETE FROM instead of ALTER TABLE DELETE. ### What changed? Modified the query string in the `deleteBatch` function to use `DELETE FROM` syntax instead of `ALTER TABLE DELETE` when removing data from ClickHouse tables. ### How to test? 1. Execute delete operations on ClickHouse tables 2. Verify that records are successfully deleted 3. Check that the operation completes without any syntax errors ### Why make this change? The `ALTER TABLE DELETE` syntax is deprecated in newer versions of ClickHouse. Using `DELETE FROM` is the standard and recommended approach for delete operations, ensuring better compatibility and maintainability.
2 parents 32f151a + 5056f39 commit 7aeffe8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/storage/clickhouse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ func (c *ClickHouseConnector) DeleteBlockData(chainId *big.Int, blockNumbers []*
10031003
}
10041004

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

10081008
blockNumbersStr := make([]string, len(blockNumbers))
10091009
for i, bn := range blockNumbers {

0 commit comments

Comments
 (0)