✦ v9.9.0 · 169 Phases · Production Ready
The Database Engine

Built From
Scratch.

166 phases. 1221 tests. 5 network protocols. Zero dependencies.
A complete relational database engine with ACID transactions, PostgreSQL Wire Protocol, GraphQL API, CDC, WebSocket, WASM, Multi-Tenant, HA Sentinel, and adaptive query optimizer.

CI passing C++17 0 dependencies 152 phases Production Ready
milansql_demo.sql
-- Adaptive Optimizer (Phase 82)
SET QUERY_REWRITE = ON;

-- Column Store for OLAP (Phase 80)
CREATE COLUMN TABLE sales (
  id     INT PRIMARY KEY,
  amount REAL,
  region TEXT
);

-- Window Functions + Inheritance
SELECT region,
  SUM(amount) OVER(
    PARTITION BY region
  ) AS total
FROM sales
WHERE amount > 100;

-- SHOW INDEX SUGGESTIONS;
-- → CREATE INDEX idx_sales_region
-- → 85% der Queries filtern nach region
166
Development Phases
1221
Automated Tests
5
Network Protocols
0
External Dependencies

Everything a database needs.
Nothing it doesn't.

Built phase-by-phase from the ground up — every feature is hand-crafted in pure C++17 without a single external library.

🔒

ACID Transactions

Full MVCC with Write-Ahead Logging, SAVEPOINT, ROLLBACK TO SAVEPOINT, and SELECT FOR UPDATE row-level locking — battle-tested durability.

Learn more →
⚡

Zero Dependencies

Pure C++17 standard library only. No Boost, no OpenSSL, no third-party headers. Clone, compile, run — on Linux, Windows, or macOS.

View source →
🌐

5 Network Protocols

TCP(4406) + MySQL Wire(4407) + PostgreSQL Wire(5433) + REST/HTTP(8080) + GraphQL(8081). Connect with psql, mysql CLI, curl, or any HTTP client.

Get started →
📊

Analytics — Column Store

CREATE COLUMN TABLE for OLAP workloads. Columnar SUM/AVG/COUNT/MIN/MAX scans, GROUP BY fallback, and SHOW STORAGE FORMAT to compare row vs column store.

See example →
🔄

Physical + Logical Replication

Binary-log master/slave replication with auto-sync, PLUS logical replication via CREATE PUBLICATION / CREATE SUBSCRIPTION with append-only change log.

Learn more →
🛡️

Row-Level Security

ENABLE/DISABLE RLS per table, CREATE POLICY with USING expressions, CURRENT_USER_ID() predicate substitution, and persistent policy storage.

Learn more →
🔍

Full-Text Search

FULLTEXT INDEX with MATCH … AGAINST syntax and TF-based relevance scoring across multiple columns — no external search engine required.

See example →
📅

Event Scheduler

MySQL-compatible CREATE EVENT with EVERY n SECOND/MINUTE/HOUR/DAY schedules and AT timestamp one-shot events — background job execution built in.

Learn more →
🧠

Adaptive Query Optimizer

Automatic query rewriting (removes WHERE 1=1, redundant conditions), access statistics tracking, and automatic index suggestions via SHOW INDEX SUGGESTIONS.

See example →
📡

Change Data Capture (CDC)

ALTER TABLE … ENABLE CDC tracks every INSERT/UPDATE/DELETE as a change event. Query CDC streams with AFTER SEQUENCE N for real-time data pipelines.

Learn more →
📊

GraphQL API

Built-in GraphQL server on port 8081. Query any table with auto-generated schema, field filtering, and an in-browser GraphQL playground — no config needed.

Get started →
🗜️

Data Compression

LZ4, RLE, Dictionary, and ZSTD compression engines for page-level storage. Transparent to queries — compresses cold data automatically.

Learn more →
⏱️

Time-Series Optimizations

time_bucket() aggregation, retention policies, and partitioned time-series tables. Efficient range scans and automatic partition pruning for metrics workloads.

See example →

SQL you already know.
Features you didn't expect.

MilanSQL speaks standard SQL — and adds table inheritance, column stores, pub/sub, and more.

-- Phase 78: Table Inheritance
CREATE TABLE person (id INT PRIMARY KEY, name TEXT);
CREATE TABLE employee (salary REAL) INHERITS (person);

INSERT INTO person   VALUES (1, 'Alice');
INSERT INTO employee VALUES (2, 'Bob', 75000);

SELECT * FROM person;          -- returns Alice + Bob (inherited)
SELECT * FROM ONLY person;     -- returns only Alice

-- Phase 75: Row-Level Security
ENABLE ROW LEVEL SECURITY ON employee;
CREATE POLICY own_rows ON employee
  FOR SELECT TO alice
  USING (id = CURRENT_USER_ID());

-- Phase 82: Adaptive Optimizer
SET QUERY_REWRITE = ON;
EXPLAIN REWRITTEN SELECT * FROM employee WHERE 1=1;
-- Rewrite: removed always-true condition WHERE 1=1

SHOW INDEX SUGGESTIONS;
-- CREATE INDEX idx_employee_salary ON employee(salary)  -- 78%

-- Phase 76: LISTEN / NOTIFY pub/sub
LISTEN updates;
NOTIFY updates, 'new_employee_added';
# DB-API 2.0 compatible Python client (stdlib only)
import milansql

# Connect via DSN (Phase 79)
conn = milansql.connect("milansql://root:pass@localhost:4406/mydb")
cursor = conn.cursor()

# Execute SQL
cursor.execute("""
    CREATE TABLE orders (
        id    INT PRIMARY KEY AUTO_INCREMENT,
        item  TEXT NOT NULL,
        price REAL
    )
""")

cursor.execute("INSERT INTO orders VALUES (NULL, 'Laptop', 999.99)")
conn.commit()

# Fetch results
cursor.execute("SELECT * FROM orders WHERE price > %s", (100,))
rows = cursor.fetchall()
for row in rows:
    print(row)

conn.close()
# Start REST API server
$ ./build/milansql.exe --http --port 8080

# Execute a query via HTTP POST
$ curl -s -X POST http://localhost:8080/query \
  -H 'Content-Type: application/json' \
  -d '{"sql": "SELECT * FROM orders LIMIT 10"}'

# Response (JSON)
{
  "columns": ["id", "item", "price"],
  "rows": [
    ["1", "Laptop", "999.99"]
  ],
  "rowCount": 1,
  "elapsed_ms": 0.42
}

# Web Dashboard available at:
$ open http://localhost:8080/

# List tables
$ curl http://localhost:8080/tables

# Health check
$ curl http://localhost:8080/health
"OK"

Clean layers.
Header-only C++17.

Every component lives in a single .hpp file. No build magic — just CMake and a C++17 compiler.

Clients
→
REPL / CLI Python Client Node.js Client curl / REST DSN milansql://
Protocol
→
TCP Server :4406 HTTP/REST :8080 Web Dashboard LISTEN / NOTIFY Pub/Sub
Engine
→
SQL Parser Dispatcher DML / DDL Executor Transaction Manager Query Cache
Optimizer
→
Query Rewriter Adaptive Stats Index Selector Parallel Executor Join Reorderer
Storage
→
Row Store (Binary v9) Column Store (OLAP) WAL Journal Buffer Pool Logical Repl Log

Everything you need
to get started.

Comprehensive guides, SQL reference, and architecture docs — all in one place.

📖

SQL Reference

Complete reference for all SQL commands — DDL, DML, transactions, window functions, CTEs, and MilanSQL-specific extensions.

Open reference →
🎓

Tutorial

Step-by-step tutorial from first query to advanced features — joins, transactions, replication, and client drivers.

Start tutorial →
🏗️

Architecture

Deep-dive into the query pipeline, storage format, optimizer layers, and concurrency model of MilanSQL.

Explore architecture →

Up and running
in three steps.

No package manager, no Docker, no config files. Just a C++17 compiler and CMake.

1

Clone & Build

git clone https://github.com/
  haidari9819-lang/milansql
cd milansql
cmake -B build -G Ninja
cmake --build build
2

Start the Server

# HTTP + Web Dashboard
./build/milansql.exe \
  --http --port 8080

# TCP Server
./build/milansql.exe \
  --server --port 4406

# Interactive REPL
./build/milansql.exe
3

Connect & Query

# Via REST API
curl -X POST \
  http://localhost:8080/query \
  -H 'Content-Type: application/json'\
  -d '{"sql":"SHOW TABLES"}'

# Via DSN (Python)
import milansql
conn = milansql.connect(
  "milansql://root@localhost/db"
)