Mist Database Enhanced In-Memory MySQL Engine

A lightweight, thread-safe SQL database with full MySQL syntax, nested transactions, and referential integrity. Perfect for Unit Testing, Embedded Prototyping, and Development.

Why Mist?

Pure in-memory operations for sub-millisecond query performance.

Full MySQL syntax support via abbychau/mysql-parser. Swap-in replacement.

Nested transactions and savepoints for complex state management.

AOF persistence and snapshots for data durability with instant recovery.

Installation

go get github.com/abbychau/mist
git clone https://github.com/abbychau/mist
cd mist && go install ./cmd/mist
docker pull abbychau/mist:latest
docker run -p 3306:3306 abbychau/mist:latest

Getting Started

// Full MySQL persistence and engine setup
engine := mist.NewSQLEngineWithOptions(mist.PersistenceOptions{
    AofPath: "data.aof",
    SyncInterval: time.Second,
})

// Advanced Schema & Querying
engine.Execute("CREATE TABLE orders (id INT, amount DECIMAL(10,2), status ENUM('paid', 'pending'))")
result, _ := engine.Execute(`
    SELECT status, COUNT(*) as count, SUM(amount) as total 
    FROM orders GROUP BY status 
    HAVING total > 500
`)
-- JOIN with Aggregation and Conditional Logic
SELECT 
    c.name AS category,
    COUNT(p.id) AS product_count,
    ROUND(AVG(p.price), 2) AS avg_price,
    SUM(CASE WHEN p.stock < 10 THEN 1 ELSE 0 END) AS low_stock_items
FROM categories c
LEFT JOIN products p ON c.id = p.category_id
GROUP BY c.id;

-- Correlated Subquery support
SELECT name, (
    SELECT COUNT(*) FROM orders WHERE user_id = u.id
) as total_orders FROM users u;

Background Operation

# Start Mist in daemon mode
./mist -d --port 3306 --persist data.aof

# With snapshot support
./mist -d --port 3306 --persist data.aof --snapshot data.rdb
services:
  mist:
    image: abbychau/mist:latest
    ports:
      - "3306:3306"
    volumes:
      - ./data:/data
    command: ["-d", "--port", "3306", "--persist", "/data/mist.aof"]
# Run with persistence
docker run -p 3306:3306 -v ./data:/data \\
  abbychau/mist:latest -d --port 3306 --persist /data/mist.aof

# Run without persistence
docker run -p 3306:3306 abbychau/mist:latest