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.
import { OlapTable, ClickHouseEngines } from "@514labs/moose-lib"; interface Event { id: string; timestamp: Date; user_id: string; action: string; properties: Record<string, any>;} // MergeTree is the default—no engine parameter neededconst events = new OlapTable<Event>("events", { orderByFields: ["timestamp", "user_id", "id"]}); // Or explicitly specifyconst explicitEvents = new OlapTable<Event>("events", { engine: ClickHouseEngines.MergeTree, orderByFields: ["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.