MergeTree is the default engine for OlapTable and the most commonly used ClickHouse table engine. It's optimized for high-volume inserts and fast analytical queries on append-only data.
from moose_lib import OlapTable, OlapConfigfrom moose_lib.blocks import MergeTreeEnginefrom pydantic import BaseModelfrom datetime import datetimefrom typing import Dict, Any class Event(BaseModel): id: str timestamp: datetime user_id: str action: str properties: Dict[str, Any] # MergeTree is the default—no engine parameter neededevents = OlapTable[Event]("events", OlapConfig( order_by_fields=["timestamp", "user_id", "id"])) # Or explicitly specifyexplicit_events = OlapTable[Event]("events", OlapConfig( engine=MergeTreeEngine(), order_by_fields=["timestamp", "user_id", "id"]))| Option | Description |
|---|---|
orderByFields | Columns for sorting and primary index (critical for query performance) |
partitionBy | Partition expression (e.g., toYYYYMM(timestamp)) |
settings | Engine-specific settings as key-value pairs |
The orderByFields determines both the sort order and the primary index. Place your most common filter columns first for best query performance.