Skip to content

Conversation

@iuwqyir
Copy link
Contributor

@iuwqyir iuwqyir commented Jan 13, 2025

TL;DR

Improved the deletion logic in case of reorgs in ClickHouse by implementing partition-aware deletes and disabling lightweight delete synchronization.

What changed?

  • Added lightweight_deletes_sync setting (value 0) to ClickHouse configuration. This will make the deletes async, so processing does not need to wait for it to finish
  • Split generic deleteBatch function into specific delete functions for blocks, logs, transactions, and traces, which will improve performance due to having all of the order by keys defined
  • Implemented two-step deletion process:
    1. Query for existing records that need deletion
    2. Execute targeted deletes using partition values and primary keys
  • Added proper error handling and batch processing for deletions

Why make this change?

The previous deletion method was inefficient and could cause performance issues in ClickHouse.

Copy link
Contributor Author

iuwqyir commented Jan 13, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@iuwqyir iuwqyir marked this pull request as ready for review January 13, 2025 19:17
@iuwqyir iuwqyir force-pushed the 01-13-improve_delete_performance_for_clickhouse branch from 074cd78 to e5a19e4 Compare January 13, 2025 22:25
@iuwqyir iuwqyir force-pushed the 01-13-improve_delete_performance_for_clickhouse branch from e5a19e4 to 3aea63b Compare January 14, 2025 21:47
@iuwqyir iuwqyir requested a review from catalyst17 January 14, 2025 21:50
@iuwqyir iuwqyir force-pushed the 01-13-improve_delete_performance_for_clickhouse branch from 3aea63b to 7e42585 Compare January 15, 2025 11:12
@iuwqyir iuwqyir merged commit 9538ef4 into main Jan 15, 2025
5 checks passed
@iuwqyir iuwqyir deleted the 01-13-improve_delete_performance_for_clickhouse branch January 15, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants