Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize ClickHouse table schemas and indexing #100

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

iuwqyir
Copy link
Collaborator

@iuwqyir iuwqyir commented Oct 11, 2024

TL;DR

Optimized ClickHouse table structures for improved query performance and data organization.

What changed?

  • Changed order by to include block number, because most queries would be ordering by time (equivalent to block numbers) or fetching a specific block data by number, not by hash
  • Introduced a function_selector column in the transactions table
  • Indexing every log topic to be able to query based on them

How to test?

  1. Apply the SQL changes to a test ClickHouse instance
  2. Verify that the tables are created successfully
  3. Insert sample data into each table
  4. Run queries using the new indexes and ordering to ensure improved performance
  5. Compare query execution times with the previous table structure

Why make this change?

These changes aim to:

  1. Enhance query performance by using more appropriate index types (e.g., bloom_filter for hash columns)
  2. Improve data organization and retrieval efficiency with updated ORDER BY clauses
  3. Enable faster filtering on commonly used columns with additional indexes
  4. Support function-based queries in the transactions table with the new function_selector column

These optimizations will lead to faster data access and improved overall system performance, especially for large-scale blockchain data analysis.

Copy link
Collaborator Author

iuwqyir commented Oct 11, 2024

@iuwqyir iuwqyir changed the title schema changes Optimize ClickHouse table schemas and indexing Oct 11, 2024
@iuwqyir iuwqyir marked this pull request as ready for review October 11, 2024 15:04
@iuwqyir iuwqyir changed the base branch from 10-10-remove_final_from_clickhouse_queries_where_possible to graphite-base/100 October 11, 2024 19:15
@iuwqyir iuwqyir force-pushed the 10-11-schema_changes branch from 4658e57 to ac15e0f Compare October 11, 2024 19:15
@iuwqyir iuwqyir changed the base branch from graphite-base/100 to main October 11, 2024 19:16
@iuwqyir iuwqyir force-pushed the 10-11-schema_changes branch from ac15e0f to ffc2481 Compare October 11, 2024 19:16
Copy link
Collaborator Author

iuwqyir commented Oct 15, 2024

Merge activity

  • Oct 15, 1:50 PM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Oct 15, 1:50 PM EDT: A user merged this pull request with Graphite.

@iuwqyir iuwqyir merged commit 0beab4a into main Oct 15, 2024
5 checks passed
@iuwqyir iuwqyir deleted the 10-11-schema_changes branch October 15, 2024 17:50
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.

2 participants