MygramDB vs Elasticsearch vs MySQL FULLTEXT
Choosing the right full-text search solution depends on your requirements. Here's a detailed comparison.
Quick Comparison
| Feature | MygramDB | Elasticsearch | MySQL FULLTEXT |
|---|---|---|---|
| Latency | <80ms | 50-500ms | 100-3000ms |
| Deployment | Single binary | Cluster | Built-in |
| Data sync | MySQL binlog | ETL required | Native |
| Scalability | Single node | Distributed | Single node |
| Memory | ~1-2GB/1M docs | ~2-4GB/1M docs | Buffer pool |
| Concurrency | QPS 372 | High | QPS 0.4 |
| CJK support | N-gram | Plugins | N-gram parser |
| Analytics | Basic | Advanced | None |
| Learning curve | Low | High | Low |
Detailed Comparison
MygramDB
Best for: MySQL-based applications needing fast search without infrastructure complexity.
Pros:
- Sub-80ms consistent latency
- Zero configuration data sync via binlog
- Single binary deployment
- No cluster management
- Perfect for CJK text with N-gram
Cons:
- Single node only (no distributed search)
- Data must fit in RAM
- Basic query features (no fuzzy, highlighting)
Elasticsearch
Best for: Large-scale search with advanced analytics requirements.
Pros:
- Horizontal scalability
- Advanced features (fuzzy, highlighting, aggregations)
- Rich ecosystem and tooling
- Handles petabytes of data
Cons:
- Complex cluster management
- ETL pipeline required
- Higher operational cost
- Steeper learning curve
- JVM tuning required
MySQL FULLTEXT
Best for: Simple search on small datasets (<100K rows).
Pros:
- No additional infrastructure
- Native MySQL integration
- Zero data sync overhead
Cons:
- Slow (100-3000ms per query)
- Fails under concurrent load (90% failure at 10 concurrent)
- Cache-dependent performance
- Limited scalability
Performance Comparison
Tested on 1.7M rows, 10 concurrent queries:
| Metric | MygramDB | Elasticsearch* | MySQL FULLTEXT |
|---|---|---|---|
| Success rate | 100% | ~100% | 10% |
| Avg latency | 35ms | 100-200ms | 4,641ms |
| QPS | 288 | 50-100 | 0.4 |
*Elasticsearch performance varies significantly based on cluster configuration.
Migration Path
From MySQL FULLTEXT to MygramDB
- Keep MySQL as primary database
- Deploy MygramDB alongside
- Point search queries to MygramDB
- Write operations remain on MySQL
bash
# 1. Start MygramDB
docker run -d -p 11016:11016 \
-e MYSQL_HOST=your-mysql \
ghcr.io/libraz/mygram-db:latest
# 2. Search via MygramDB
curl "http://localhost:8080/articles/search" \
-d '{"q": "search term"}'From Elasticsearch to MygramDB
Consider migrating if:
- You don't need distributed search
- Data fits in single-node RAM
- Operational complexity is a concern
- You want simpler MySQL integration
See GitHub for more details.