MySQL FULLTEXT too slow?
Route heavyweight FULLTEXT reads to an in-memory search index. See the reproducible benchmarks for measured latency and throughput.
An in-memory index that follows the MySQL / MariaDB binlog. Writes stay in MySQL; search moves to MygramDB.
MygramDB runs as a sidecar next to MySQL or MariaDB. Your application keeps writing to the database as before. MygramDB follows the binlog into its own in-memory index, and only search queries go to MygramDB.
Turn on GTID mode and create a replication user. MygramDB reads the binlog (MySQL's change log) and uses GTIDs to track how far it has read; see the Glossary.
SET GLOBAL enforce_gtid_consistency = ON;
SET GLOBAL gtid_mode = OFF_PERMISSIVE;
SET GLOBAL gtid_mode = ON_PERMISSIVE;
SET GLOBAL gtid_mode = ON;
SET GLOBAL binlog_format = ROW;
SET GLOBAL binlog_row_image = FULL;
SET GLOBAL binlog_row_metadata = FULL;
CREATE USER 'repl_user'@'%' IDENTIFIED BY 'your_password';
-- SELECT: for initial snapshot of search target tables
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'repl_user'@'%';
GRANT SELECT ON mydb.* TO 'repl_user'@'%';Persist the settings
SET GLOBAL values can reset on restart. In production, keep log_bin on and also set gtid_mode=ON, binlog_format=ROW, binlog_row_image=FULL and binlog_row_metadata=FULL in my.cnf or your managed parameter group. Upgrading an existing deployment? Follow the upgrade checklist first.
export API_ADMIN_TOKEN="$(openssl rand -hex 32)"
docker run -d --name mygramdb \
-p 127.0.0.1:11016:11016 -p 127.0.0.1:8080:8080 \
-e API_BIND=0.0.0.0 -e API_HTTP_BIND=0.0.0.0 \
-e API_ADMIN_TOKEN \
-e MYSQL_HOST=your-mysql-host \
-e MYSQL_USER=repl_user \
-e MYSQL_PASSWORD=your_password \
-e MYSQL_DATABASE=mydb \
-e TABLE_NAME=articles \
-e TABLE_PRIMARY_KEY=id \
-e TABLE_TEXT_COLUMN=content \
-e TABLE_NGRAM_SIZE=2 \
-e REPLICATION_SERVER_ID=12345 \
-e NETWORK_ALLOW_CIDRS=127.0.0.1/32,::1/128,172.16.0.0/12 \
ghcr.io/libraz/mygram-db:1.14.0Network allowlist
Set NETWORK_ALLOW_CIDRS to the subnet MygramDB actually sees clients from; 172.16.0.0/12 is a local Docker bridge example. Keep the loopback entries for in-container clients and health checks. A 0.0.0.0/0 allowlist with a non-loopback container listener is rejected. See Docker deployment.
MygramDB does not import existing rows on startup. Run SYNC once to build the index from MySQL, check SYNC STATUS, then search.
docker exec -it mygramdb mygram-cliAUTH <API_ADMIN_TOKEN>
SYNC articles
SYNC STATUS
SEARCH articles hello worldOfficial clients for Node.js, Go and Python. The client guide covers connection options, filters and error handling.
import { createMygramClient } from 'mygramdb-client'
const client = createMygramClient({ host: 'localhost', port: 11016 })
await client.connect()
const results = await client.search('app_db.articles', 'hello world', {
limit: 10
})import mygram "github.com/libraz/go-mygram-client"
client := mygram.NewClient("localhost:11016")
defer client.Close()
client.Connect()
resp, _ := client.Search("app_db.articles", "hello world", mygram.SearchOptions{
Limit: 10,
})from mygramdb_client import MygramClient, ClientConfig, SearchOptions
async with MygramClient(ClientConfig(host='localhost', port=11016)) as client:
results = await client.search(
'app_db.articles',
'hello world',
SearchOptions(limit=10),
)