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
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplates
Changelog
Source508
  • 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
  • Changelog
Contribution
  • Documentation
  • Framework