Skip to content

Frequently Asked Questions ​

Unfamiliar with a term?

GTID, binlog, n-gram, BM25, and Roaring bitmap are all defined in the Glossary. Keep it open alongside this page on a first read.

MySQL FULLTEXT Problems ​

Why is my MySQL FULLTEXT search so slow? ​

MySQL FULLTEXT latency depends on the query, data, sorting, buffer-pool state, and concurrency. The architecture comparison explains the search paths; the published benchmark used a 99.9996% buffer-pool hit ratio, so per-query disk reads do not explain its measured difference.

Solution: MygramDB keeps its search index in memory. See Benchmarks for the current cache-off measurements.

What you do have to change

Writes to MySQL stay exactly as they are. What changes is where search requests go: they must be pointed at MygramDB's TCP or HTTP API.

My MySQL FULLTEXT queries keep timing out under load. How do I fix it? ​

Add MygramDB as a search replica. The reproducible benchmark compares its cache-off throughput with MySQL FULLTEXT on the same dataset.

Can I speed up MySQL FULLTEXT without changing my application? ​

MygramDB leaves MySQL writes in place, but it uses its own TCP and HTTP search APIs. Change the application's search path to call MygramDB; existing MySQL FULLTEXT SQL queries do not become faster automatically. See Getting Started for setup.

Alternatives ​

Should I use a distributed search engine instead of MygramDB? ​

Your situationBetter fit
The data lives in MySQL or MariaDB and fits in one node's RAMMygramDB
The index must span multiple nodes, or the data is too large for one node's RAMDistributed search engine
You need advanced analytics and aggregationDistributed search engine

See Comparison for a detailed breakdown.

How does MygramDB compare to a standalone search server? ​

Standalone search serverMygramDB
How documents reach the indexYour application or a connector sends themRead from the MySQL or MariaDB binlog; the application sends nothing
Data sourcesAnyMySQL and MariaDB only
Fits whenThe data lives elsewhere, or its feature set matches your search requirements betterThe data already lives in MySQL or MariaDB

Compare current features, deployment requirements, and license terms before choosing.

Features and Limitations ​

How much memory does MygramDB need? ​

The published v1.14.0 benchmark measured ~2GB of resident memory per million documents with verify_text: all, including the index, stored text, and process overhead. A linear estimate for 10M similar documents is ~20GB before headroom. Current builds retain normalized text even with verify_text: off because highlighting can be requested at query time. That setting controls post-filtering, so do not use an index-only estimate for it. Measure memory with your own content and leave headroom.

What happens when memory runs out

MygramDB is an in-memory engine. If the dataset outgrows available RAM, the OS or container platform can kill the process with an OOM. In production, budget index RAM plus headroom, separately from the disk space used for dumps.

Does MygramDB handle multibyte / non-ASCII text? ​

Yes. MygramDB is fully Unicode-aware: text goes through ICU-based NFKC normalization and is then tokenized by a language-agnostic n-gram tokenizer. 3-byte UTF-8 (most ideographic scripts, e.g. Chinese, Japanese, Korean) and 4-byte UTF-8 (emoji, supplementary planes) are handled out of the box with no language-specific plugins, dictionaries, or morphological analyzers to configure.

Does MygramDB support fuzzy search or typo tolerance? ​

Yes. Add FUZZY (or FUZZY 2) to match terms within a Levenshtein edit distance of 1 or 2. Fuzzy search also includes every result from the same non-fuzzy query, including short terms and mixed CJK/ASCII terms. See Query Guide — Fuzzy Search.

Does MygramDB support search result highlighting? ​

Yes. Add the HIGHLIGHT clause to receive snippet fragments with configurable tags (TAG), fragment length (SNIPPET_LEN), and fragment count (MAX_FRAGMENTS). The server retains normalized text for highlighting even with memory.verify_text: "off". See Query Guide — Highlighting.

Does MygramDB support relevance ranking? ​

Yes. Use SORT _score DESC to rank results by BM25 relevance. IDF and TF are computed at query time; k1 and b are tunable via bm25.k1 (default 1.2) and bm25.b (default 0.75). Set bm25.enable: true; normalized text is retained for scoring independently of memory.verify_text.

Can MygramDB scale horizontally? ​

MygramDB does not shard an index across nodes. Multiple full replicas can serve search traffic behind a load balancer, but each holds the whole index and needs its own replication configuration, including a distinct replication.server_id. Route traffic only to ready instances. If the data does not fit in one node's RAM, partition the source data across separately indexed tables or instances and route or combine queries in the application.

Capacity depends on document size and filters. The published benchmark used about 2 GB per million documents with verify_text: all; measure your own data and leave room for indexing and maintenance before choosing a node size.

Can I search across multiple tables? ​

No. Each query targets a single table: SEARCH articles hello world. MygramDB supports configuring multiple tables, but each has its own independent index and document store. Cross-table search would need to be handled at the application layer with separate queries.

Can one MygramDB instance index multiple MySQL databases? ​

Yes (v1.7.0+). Each table has an effective identity of <database>.<table>. If all configured tables belong to one database, bare names like articles continue to work. If the configuration spans two or more databases, table references must be qualified, for example SEARCH app_db.articles mysql or POST /tables/app_db.articles/search.

Does MygramDB support databases other than MySQL and MariaDB? ​

No. MygramDB follows changes through the binary log replication protocol, and its supported sources are MySQL and MariaDB only. There are no current plans to support other databases.

Does MygramDB work with MariaDB? ​

Yes. MygramDB supports MariaDB 10.11+/11.x/12.x using MariaDB-native GTIDs (domain-server-sequence). A capability probe detects the server flavor, so the same mysql config section works for both MySQL 8.4/9.7/26.x and MariaDB. The E2E matrix covers MariaDB 10.11, 11.4, 11.8, and 12.3.

Why N-gram instead of morphological analysis? ​

N-gram tokenization is language-agnostic. Morphological analyzers (MeCab, kuromoji, jieba) require dictionaries, language detection, and version management. N-gram works uniformly across Latin, multibyte ideographic scripts, and mixed-script content without any per-language configuration.

MygramDB uses bigrams (size 2) by default for ASCII/alphanumeric text and CJK ideographs. Set kanji_ngram_size when CJK ideographs need a different size. Both sizes are configurable per table, and the omitted ngram_size default is 2.

How are Roaring bitmaps used? ​

Posting lists use delta encoding or Roaring bitmaps. OPTIMIZE chooses a representation based on density, and inserts can trigger a conversion based on list size:

PostingsConditionRepresentation
SparseTypically below 18% density after OPTIMIZEDelta-encoded arrays. DocIDs are stored as fixed-width deltas from the previous value.
DenseTypically at least 18% density after OPTIMIZE, or over 4,096 entries after insertsRoaring bitmaps via CRoaring, which selects a container type (array, bitmap, or run-length) per 65,536-ID chunk.

The density threshold is configurable (roaring_threshold, 18% by default), with a 0.5x hysteresis factor for OPTIMIZE. Inserts convert a delta list to Roaring when it grows beyond 4,096 entries, regardless of density. A Roaring list converts back only when it has at most 4,096 entries and its density is below half the threshold (9% by default).

What does "SIMD-accelerated" mean in practice? ​

MygramDB links against CRoaring, which uses SIMD instructions internally for bitmap operations (AND, OR, cardinality). On x86-64, CRoaring uses AVX2 when available; on ARM, it uses NEON. MygramDB does not contain custom SIMD code. The acceleration comes from the bitmap library.

How are posting lists encoded? ​

As delta-encoded arrays for sparse terms and Roaring bitmaps for dense terms; the table under How are Roaring bitmaps used? gives the switching rules. Delta encoding turns increasing DocIDs such as [1000, 1002, 1005] into [1000, 2, 3] and stores each delta as a uint32_t. Roaring bitmaps use run-length containers for consecutive ranges and bitmap containers for scattered dense regions.

Memory usage depends on the document-ID distribution, so there is no fixed compression ratio across datasets. Measure index memory with your own content and see the published memory breakdown.

Replication and Data Sync ​

Who decodes the binlog? ​

MygramDB receives the raw binlog stream through the MySQL C API (mysql_binlog_open()) and decodes it with libmybinlog, a separate C++17 library that carries the MySQL and MariaDB wire-format rules: framing, checksums, TABLE_MAP, GTIDs, QUERY events, and row events. MygramDB applies the decoded row events to its index and handles the DDL it cares about, such as TRUNCATE and ALTER TABLE. mysql-event-stream, a standalone CDC library with Node.js and Python bindings, decodes through libmybinlog as well. See Binlog Decoding for the full path.

How fast is replication? INSERT to searchable? ​

Replication lag depends on source transactions, network conditions, event queueing, and index updates. Monitor mygramdb_replication_last_applied_unixtime and mygramdb_replication_seconds_since_last_applied at /metrics, alongside MySQL write activity. When api.admin_token is configured, Prometheus must send a valid Bearer token to receive these metrics. An idle source can have an old last-applied time without being behind.

What happens during MySQL failover? ​

MygramDB detects connection loss and retries the configured endpoint. On reconnection:

  1. The current GTID position is preserved
  2. The source server UUID is checked; a different source is rejected
  3. If the source is unchanged, binlog replication resumes from the saved GTID

mysql.host and mysql.port cannot be changed with SET. To move to another endpoint, edit the configuration and restart after confirming the intended source. Monitor readiness and replication lag while the reader reconnects.

How does MygramDB handle ALTER TABLE? ​

An ALTER TABLE that does not touch configured columns continues after a warning. An incompatible change to a configured primary-key, text-source, or filter column stops replication before its GTID advances, as do dropping or renaming a configured table and removing the single-column PRIMARY KEY or UNIQUE index behind a configured primary key. TRUNCATE TABLE clears the affected index.

After a stop, the existing index is retained but is no longer current. Fix the schema or configuration, then run SYNC to rebuild the table. DDL Operations lists each statement with its recovery.

How are deletes handled in the index? ​

Immediate removal. When a DELETE event arrives via binlog, the document's n-grams are removed from posting lists and the document is removed from the document store. No tombstones, no lazy deletion. Cache entries referencing the deleted document are invalidated.

Crash Recovery and Persistence ​

What happens on crash? Is there a WAL? ​

No WAL. MygramDB uses snapshot-based persistence.

  1. Periodic or manual DUMP SAVE writes the index state with its GTID position. Scheduled dumps have timestamped filenames.
  2. If dump.load_on_startup: true, startup tries dump.dir/default_filename, not the newest timestamped dump. On success, replication resumes from the dump's GTID. Set replication.start_from: snapshot for this mode.

If that startup dump is missing or invalid, MygramDB falls back to a MySQL initial snapshot. MySQL remains the source of truth; keep its own backup and binlogs separately. See Snapshot and Dump Recovery for restore checks.

If the dump restores but MygramDB cannot catch up to the current MySQL position, it keeps serving the restored index with replication stopped and reports not_ready. Check the replication error and source GTID/binlog availability, then follow Snapshot and Dump Recovery to recover or rebuild the index.

Dump settings:

SettingDefaultDescription
dump.interval_sec0 (disabled)Auto-save interval in seconds (0–86400).
dump.retain3Number of dumps to keep.

What happens when memory reaches the hard limit? ​

MygramDB reports memory usage but does not enforce the hard limit by rejecting queries or stopping replication. If the index grows beyond available RAM, the OS-level OOM killer can terminate the process. Size the server for the full dataset plus headroom (the measured reference is ~2GB per million documents with verify_text: all; see How much memory does MygramDB need?), and watch the trend in /health/detail or the Prometheus metrics.

Protocol and Security ​

What's the query protocol? ​

A custom line-oriented text protocol over TCP (default port 11016): each command is one line terminated by \r\n. A separate REST/JSON HTTP API is also available on its own port (default 8080, disabled by default).

TCP example:

mygram
SEARCH articles golang SORT created_at DESC LIMIT 10\r\n

HTTP example:

bash
curl -X POST http://localhost:8080/tables/articles/search \
  -H "Content-Type: application/json" \
  -d '{"q": "golang", "sort": {"column": "created_at", "order": "DESC"}, "limit": 10}'

In multi-database deployments, qualify the route as /tables/app_db.articles/search. It is not SQL. The protocol is intentionally minimal: search, count, facet, get by ID, and admin commands.

Is there TLS or authentication? ​

SurfaceProtection
Client connections (TCP and HTTP)No native TLS; terminate TLS at a reverse proxy or load balancer
MySQL replication connectionSSL/TLS for the binlog transfer
Administrative TCP commandsAUTH <token> on each connection when api.admin_token is set
HTTP GET /config, GET /replication/status, POST /optimizeAuthorization: Bearer <token> on each request when api.admin_token is set
Search endpointsListener bind address and network.allow_cidrs

Without authentication, TCP INFO omits its # Replication section and /metrics omits the mygramdb_replication_ metrics. Keep the service on a private network or behind a reverse proxy or firewall.

Deployment and Monitoring ​

Can MygramDB run on Kubernetes? ​

MygramDB exposes health checks and metrics that can be used by a Kubernetes deployment. You still need to configure storage for dumps, memory limits, probes, and network access to MySQL for your cluster.

EndpointUseResponse
GET /health/liveLiveness probe200 if the process is running.
GET /health/readyReadiness probe503 while the initial load is incomplete (in progress, waiting to retry, failed, or not started), during dump load, table sync, replication unavailability, or a failed startup catch-up after dump restore. 200 when ready. The reason field names the cause.
GET /health/detailDetailed statusUptime, index stats, and memory. Replication details require a bearer token when api.admin_token is set.

The Docker image's health check probes /health/live, so a container reports healthy while tables are still loading. Gate traffic on /health/ready. Prometheus metrics are available at GET /metrics. The Docker image runs as a non-root user (UID 1000).

What metrics are available? ​

Prometheus-format metrics at GET /metrics, including:

  • Command counts (mygramdb_command_total); derive rates from the counters
  • Index document and term counts by table
  • Cache hit rate, memory, and eviction counts
  • Process RSS and accounted index memory
  • Replication state, events processed, and time since the last applied event
  • Connected clients and denied-request counts

"Single binary" but it requires MySQL — is that really simple? ​

MygramDB is a separate search service beside an existing MySQL database. Configure GTID/binlog, a replication user, searchable tables, and network access. MySQL remains the source of writes; the application must send search requests to MygramDB's TCP or HTTP API. A separate search ETL job is unnecessary.

Benchmarks ​

What hardware were the benchmarks run on? ​

Benchmarks were run on 1,100,000 rows: 1M English and 100K Japanese Wikipedia articles with MySQL 8.4.13 in Docker. MygramDB ran with verify_text: all (normalized-substring verification enabled) and query cache disabled. The Apple M5 Max host (18 cores, 128 GiB) allocated 32 GiB to Docker Desktop (31.29 GiB visible to the containers). Each query was measured over 200 iterations after 5 warmup runs. The tested queries returned the same counts as MySQL FULLTEXT; this does not establish equivalent semantics for all queries. On other hardware and memory limits, absolute latency will differ.

Were MySQL settings tuned for the benchmark? ​

Yes. MySQL ran with innodb_buffer_pool_size at 8.0 GiB, large enough to hold the FULLTEXT working set — during the run the buffer pool hit ratio was 99.9996% with 2,700 disk reads. The numbers on the benchmark page compare against a warm, adequately sized FULLTEXT index.

Was MySQL tested cold or warm? ​

Warm. The buffer pool hit ratio during the run was 99.9996%, so MySQL FULLTEXT was reading almost entirely from memory. MygramDB's own query cache was disabled for the same run, so its numbers reflect search-engine work rather than cache hits. Both configurations are recorded on the benchmark page.

Why not benchmark against a distributed search engine with real numbers? ​

A distributed search engine's performance varies dramatically based on cluster size, heap size, shard count, and replica configuration. A single-node comparison would be misleading; a cluster comparison would be non-reproducible. The comparison page provides qualitative guidance instead.

Project ​

Why C++ and not Rust? ​

MygramDB uses C++ for direct control over the in-memory layout of posting lists, bitmap operations, and delta-encoded IDs, and to integrate with the MySQL C API and CRoaring. The code uses RAII and unique_ptr for resource ownership, and Expected<T, Error> for error handling. This describes MygramDB's implementation choices; the right language for another project depends on its constraints and libraries.

How mature is the project? ​

Development started in November 2025. MygramDB is used in production on a high-traffic service (details under NDA).

How do I migrate from MySQL FULLTEXT to MygramDB? ​

Keep MySQL as your primary database, deploy MygramDB alongside, and route search queries to its API. Build the initial index with SYNC or replication.auto_initial_snapshot; later changes are applied from the binlog. See Getting Started or Comparison — Migration Path.


Have more questions? Check GitHub or open an issue.