Benchmarks
The tables and charts below are rendered from the benchmark snapshot measured on MygramDB v1.14.0. The run uses the same dataset and query cache setting for every result shown here.
Reproducible
Run the benchmark in a clone of the repository checked out at the v1.14.0 tag:
# Requires Docker Compose and Rye.
make bench-up
# Wait for "Seed Data Load Complete" in the MySQL logs.
make bench-logs
# MygramDB logs "server_ready" when it is ready.
docker compose -f docker-compose.bench.yml logs mygramdb
make bench-run
make bench-downbench-up pulls the latest MygramDB image, so a rerun can differ from the published snapshot's version; set BENCH_MYGRAMDB_IMAGE=ghcr.io/libraz/mygram-db:1.14.0 on every target to pin it. bench-down removes the benchmark containers and volumes. The benchmark Compose configuration disables MygramDB's query cache.
At the v1.14.0 tag, bench-run measures with verify_text: all at 1, 2, 4, 8 and 16 connections. The published run limited the levels by calling support/seed/benchmark.py directly with --concurrency-levels 1,2,4,8. The snapshot file also records each consistency query's count without verification, from a second pass after the MygramDB container was recreated with MEMORY_VERIFY_TEXT=off through a Compose override file. The tag's stack also shares a Compose project with the development stack from .env, so bench-up replaces a development mysql container if one exists.
The current develop branch, not yet released, adds BENCH_VERIFY_TEXT, BENCH_CONCURRENCY_LEVELS and BENCH_JSON_OUTPUT to the make targets and runs the stack as its own Compose project, mygramdb-bench. On that branch, add -p mygramdb-bench to a direct docker compose command such as the log check above.
Benchmark Environment
1,100,000 Wikipedia articles, MySQL 8.4.13 FULLTEXT (ngram parser), MygramDB v1.14.0, verify_text: all, and the query cache disabled. Each query is measured 200 times after 5 discarded warmup runs; the tables below report p50 and p99. Measured on Apple M5 Max (18 cores, 128GB).
On this dataset the speedup is 14.9x at the median, 343x at best and 2.2x at worst.
What the MySQL baseline was given
MygramDB holds its whole index in RAM, so a MySQL left on the default 128MB buffer pool would be measured on disk I/O its opponent never had to do. The pool is set to 8GiB instead — enough to hold the 920MB table, its 124MB of secondary indexes and the 1881MB of FULLTEXT auxiliary tables outright, about 2.9GiB in all.
During this run MySQL served 99.9996% of its page requests from the buffer pool, with 2,700 disk reads. The comparison does not assume a disk read on every query. Index structure, execution plans, sorting, and concurrency can all affect the measured latency.
Applying these results to another deployment
Both latency and speedup ratios depend on hardware, data, queries, and configuration. Run make bench-up && make bench-run to repeat the benchmark on your own hardware.
Search Latency (SORT id LIMIT 100)
Bars are scaled to the largest value in each chart, with a minimum visible width for small values. Use the tables for exact values and speedup ratios.
Search Latency (SORT id LIMIT 100) (p50)
| Query Type | Matches | MySQL p50 | MySQL p99 | MygramDB p50 | MygramDB p99 | Speedup |
|---|---|---|---|---|---|---|
| Multi-word ("quantum physics") | 104 | 653.19ms | 747.41ms | 1.90ms | 3.31ms | 343x |
| Medium frequency ("quantum") | 1,961 | 510.71ms | 556.07ms | 28.19ms | 31.48ms | 18.1x |
| Low frequency ("algorithm") | 2,498 | 285.60ms | 304.77ms | 4.32ms | 5.37ms | 66.2x |
| Rare term ("fibonacci") | 84 | 325.02ms | 368.66ms | 33.20ms | 40.95ms | 9.8x |
CJK Search Latency (SORT id LIMIT 100)
CJK Search Latency (SORT id LIMIT 100) (p50)
| Query | Matches | MySQL p50 | MySQL p99 | MygramDB p50 | MygramDB p99 | Speedup |
|---|---|---|---|---|---|---|
| 日本 | 32,282 | 66.21ms | 75.11ms | 12.54ms | 15.45ms | 5.3x |
| 東京 | 6,989 | 14.55ms | 18.95ms | 2.09ms | 3.56ms | 7x |
| 科学 | 1,551 | 3.17ms | 5.23ms | 1.47ms | 2.50ms | 2.2x |
COUNT Performance
COUNT Performance (p50)
| Query Type | Count | MySQL p50 | MySQL p99 | MygramDB p50 | MygramDB p99 | Speedup |
|---|---|---|---|---|---|---|
| Medium frequency ("quantum") | 1,961 | 482.72ms | 615.30ms | 32.42ms | 46.28ms | 14.9x |
| Low frequency ("algorithm") | 2,498 | 272.06ms | 483.28ms | 5.37ms | 6.40ms | 50.6x |
Result Consistency
| Query | MySQL | MygramDB | Match |
|---|---|---|---|
| quantum | 1,961 | 1,961 | exact |
| algorithm | 2,498 | 2,498 | exact |
| 日本 | 32,282 | 32,282 | exact |
| 科学 | 1,551 | 1,551 | exact |
Concurrent Throughput
Concurrent Throughput — QPS
Query: "algorithm", 10 seconds per connection level.
| Connections | MySQL QPS | MygramDB QPS | MySQL p50 | MySQL p99 | MygramDB p50 | MygramDB p99 |
|---|---|---|---|---|---|---|
| 1 | 3.50 | 254.3 | 281.91ms | 308.91ms | 3.81ms | 5.46ms |
| 2 | 6.10 | 446.9 | 301.49ms | 653.62ms | 4.38ms | 5.78ms |
| 4 | 10.00 | 627.9 | 399.31ms | 440.74ms | 6.59ms | 8.42ms |
| 8 | 12.00 | 1,038.1 | 606.75ms | 809.01ms | 7.68ms | 11.49ms |
Memory Usage
| Documents | Index | Documents + Text | Total RSS | Per 1M docs |
|---|---|---|---|---|
| 1,100,000 | 191MB | 1.78GB | 2.15GB | ~2GB |
Docker Desktop was allocated 32 GiB; 31.29 GiB was visible to the containers.
verify_text modes
off(default): Skips text verification, so n-gram false positives can remain. Normalized text is retained in every mode.all: Checks candidates against normalized text for substring matches. The tested queries returned the same counts as MySQL FULLTEXT in this run; this does not guarantee equivalent semantics for every query.
See Why MySQL FULLTEXT is Slow for architectural details, and Comparison for product trade-offs.