Skip to content

Update balances for holders#247

Open
DenisCarriere wants to merge 2 commits intomainfrom
fix/balances-holders
Open

Update balances for holders#247
DenisCarriere wants to merge 2 commits intomainfrom
fix/balances-holders

Conversation

@DenisCarriere
Copy link
Copy Markdown
Contributor

@DenisCarriere DenisCarriere commented Apr 13, 2026

Updates

  • ReplacingMergeTree(block_num, is_deleted)
  • block_hash EPHEMERAL
  • REFRESH AFTER 60 MINUTE for *_holders MV's

Context

This pull request updates the ClickHouse schema for ERC-20 and native token balances to improve deduplication, enable efficient deletion tracking, and add materialized views for quickly accessing top token holders. The main changes are the introduction of an is_deleted column for soft deletion, adjustments to the table engines to support this, and the creation of materialized views for top holders.

Schema enhancements for soft deletion and deduplication:

  • Added an is_deleted column (materialized as balance = 0) to both erc20_balances and native_balances tables, enabling efficient tracking of deleted balances. [1] [2]
  • Changed the storage engine for both tables to use ReplacingMergeTree with the new is_deleted column as the versioning parameter, improving deduplication and deletion handling. [1] [2]
  • Marked the block_hash column as EPHEMERAL in both tables to optimize storage for transient data. [1] [2]

Materialized views for top holders:

  • Added a materialized view erc20_balances_holders to track the top 10,000 ERC-20 token holders per contract, refreshing every 60 minutes for up-to-date rankings.
  • Added a materialized view native_balances_holders to track the top 100,000 native token holders, also refreshing every 60 minutes.

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.

1 participant