1. MooseStack
  2. Table Engines
  3. MergeTree

On this page

Configuration OptionsSee Also

MergeTree

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"]});

Configuration Options

OptionDescription
orderByFieldsColumns for sorting and primary index (critical for query performance)
partitionByPartition expression (e.g., toYYYYMM(timestamp))
settingsEngine-specific settings as key-value pairs
ORDER BY matters

The orderByFields determines both the sort order and the primary index. Place your most common filter columns first for best query performance.

See Also

  • ReplacingMergeTree — When you need deduplication
  • OlapTable Reference — Full table configuration reference
  • ClickHouse MergeTree Engine — ClickHouse official documentation
  • Overview
  • Quick Start
  • Templates / Examples
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
MooseStack in your App
  • App / API frameworks
Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
  • Moose APIs
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
    • MergeTree
    • ReplacingMergeTree
    • AggregatingMergeTree
    • SummingMergeTree
    • Replicated Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Changelog
Contribution
  • Documentation
  • Framework
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplates
Changelog
Source506