ClickHouse is a highly performant and cost-effective OLAP database that can support real-time inserts. Mirror pipelines can write subgraph or blockchain data directly into ClickHouse with full data guarantees and reorganization handling. Mirror can work with any ClickHouse setup, but we have several strong defaults. From our experimentation, theDocumentation Index
Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
Use this file to discover all available pages before exploring further.
ReplacingMergeTree table engine with append_only_mode offers the best real-time data performance for large datasets.
ReplacingMergeTree engine is used for all sink tables by default. If you don’t want to use a ReplacingMergeTree, you can pre-create the table with any data engine you’d like. If you don’t want to use a ReplacingMergeTree, you can disable append_only_mode.
Full configuration details for Clickhouse sink is available in the reference page.
Secrets
Required permissions
The user will need the following permissions for the target database.- CREATE DATABASE permissions for that database
- INSERT, SELECT, CREATE, DROP table permissions for tables within that database
Data consistency with ReplacingMergeTrees
WithReplacingMergeTree tables, we can write, overwrite, and flag rows with the same primary key for deletes without actually mutating. As a result, the actual raw data in the table may contain duplicates.
ClickHouse allows you to clean up duplicates and deletes from the table by running
FINAL keyword after the table name for queries.
Append-Only Mode
Append-only mode means the pipeline will only write and not update or delete tables. There will be no mutations, only inserts. This drastically increases insert speed and reduces Flush exceptions (which happen when too many mutations are queued up). It’s highly recommended as it can help you operate a large dataset with many writes with a small ClickHouse instance. Whenappend_only_mode is true (default and recommended for ReplacingMergeTrees), the sink behaves the following way:
- All updates and deletes are converted to inserts.
is_deletedcolumn is automatically added to a table. It contains1in case of deletes,0otherwise.- If
versionColumnNameis specified, it’s used as a version number column for deduplication. If it’s not specified,insert_timecolumn is automatically added to a table. It contains insertion time and is used for deduplication. - Primary key is used in the
ORDER BYclause.
append_only_mode is false:
- All updates and deletes are propagated as is.
- No extra columns are added.
- Primary key is used in the
PRIMARY KEYclause.