FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplatesGuides
Release Notes
Source514
  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.

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

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
Build a New App
  • 5 Minute Quickstart
  • Browse Templates
  • Existing ClickHouse
Add to Existing App
  • Next.js
  • Fastify
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
Moose Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
  • Moose APIs & Web Apps
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
    • MergeTree
    • ReplacingMergeTree
    • AggregatingMergeTree
    • SummingMergeTree
    • Replicated Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Release Notes
Contribution
  • Documentation
  • Framework