-
Notifications
You must be signed in to change notification settings - Fork 2
Capacity Planning
Value Proposition Achieve robust enterprise scale with high-throughput connection pooling, token-optimized payloads, and intelligent schema caching tailored for seamless multi-agent concurrency. Read the full value proposition.
-
Connection lifecycle:
mysql2keeps idle connections alive. There is no idle timeout in the pool. Connections persist until the server process exits or MySQL closes them viawait_timeout.
Rule of Thumb: Set
--pool-sizeto 2× the expected concurrent AI tool calls. For a single-agent setup, the default of 10 provides ample headroom.
mysql-mcp's vector tools use MySQL's native VECTOR columns. They compute distances server-side via DISTANCE(). InnoDB stores vectors on disk, not in memory.
MySQL VECTOR columns store embeddings as compact binary arrays (4 bytes per float32 dimension):
| Embedding Profile | Dimensions | Storage/Row | 100K Rows | 1M Rows |
|---|---|---|---|---|
| Example Profile A | 384 | ~1.5 KB | ~150 MB | ~1.5 GB |
| Example Profile B | 1536 | ~6 KB | ~600 MB | ~6 GB |
| Example Profile C | 3072 | ~12 KB | ~1.2 GB | ~12 GB |
-
VECTOR INDEX: Use
mysql_vector_create_indexfor approximate nearest-neighbor searches on large datasets. Otherwise,mysql_vector_searchperforms full table scans. This computes distances for every row. - Distance metrics: MySQL computes COSINE (default), EUCLIDEAN, and DOT server-side. This eliminates V8 memory pressure.
-
Pre-filter with
WHERE: Use thefilterparameter on search tools. This narrows candidates before computing distance. It helps especially on unindexed tables.
The server caches schema metadata in memory. This reduces redundant INFORMATION_SCHEMA queries.
-
Default TTL:
30000ms (30 seconds), controlled viaMETADATA_CACHE_TTL_MS. - Footprint: Moderate schema metadata consumes minimal memory (e.g., a few megabytes).
- Invalidation: DDL tools automatically invalidate the cache upon execution.
| Environment | TTL | Rationale |
|---|---|---|
| Production (stable schema) |
300000 (5 min) or higher |
Eliminates introspection overhead during AI reasoning |
| Active development |
5000–30000 (5–30 s) |
Keeps AI in sync with frequent schema changes |
| Migration runs |
0 (disabled) |
Guarantees fresh metadata after every DDL statement |
export METADATA_CACHE_TTL_MS=300000AI agents rapidly modify data. This causes InnoDB tables to accumulate fragmentation. It also creates stale optimizer statistics.
InnoDB does not automatically reclaim disk space from deleted rows. OPTIMIZE TABLE rebuilds tables and indexes. This defragments the data file.
- When to use: After large bulk deletes, archival operations, or significant churn.
-
How: Use the
mysql_optimize_tabletool, or executemysql.admin.optimizeTable()via Code Mode. -
Note:
OPTIMIZE TABLElocks the table. It remains I/O-intensive. Schedule this during low-traffic windows.
- When to use: After bulk loads that change data distribution significantly. Stale statistics cause the query optimizer to choose suboptimal indexes.
-
How: Use the
mysql_admin_analyze_tabletool, or executemysql.admin.analyzeTable()via Code Mode. -
Note: For MySQL, consider using histogram statistics (
ANALYZE TABLE ... UPDATE HISTOGRAM ON ...) for columns with skewed distributions.
Consider range partitioning for exceptionally large tables or time-series segments. Use the mysql_partition_info tool to manage them. Benefits:
- Partition pruning reduces scan scope for time-bounded queries.
-
ALTER TABLE ... DROP PARTITIONis instant compared toDELETE FROM ... WHERE date < X.
The InnoDB buffer pool is MySQL's primary memory cache. Its size directly impacts query performance and serves as a cornerstone for responsive, enterprise-scale AI data operations.
-
Monitoring: Use
mysql_buffer_pool_statsto inspect hit rates, dirty page ratios, and free buffer counts. -
Sizing rule of thumb: Set
innodb_buffer_pool_sizeto 70–80% of available RAM on a dedicated MySQL server. -
Hit rate target: A hit rate below 99% indicates a pool too small for the working set. Check via
mysql_show_status→Innodb_buffer_pool_read_requestsvsInnodb_buffer_pool_reads.
Note: Administrators should use the pre-configured Grafana dashboard for ongoing capacity planning (visualizing buffer pool stats) to reduce the need for constant manual polling.
- Cost Optimization and Context Efficiency: Passing raw results directly to an LLM context window creates immediate scaling and cost bottlenecks. Code Mode acts as an intelligent processing layer, drastically reducing context bloat by aggregating data server-side.
-
Default limit: mysql-mcp enforces default limits via tool arguments (e.g. LIMIT 50 on
mysql_read_query) rather than a configurable global server default. -
Cursor pagination: Use the
cursorparameter for scanning large tables instead ofOFFSET.OFFSET 100000forces MySQL to scan and discard 100,000 rows. Cursor pagination uses keyset ordering. This executes in O(1) time on indexed columns. -
Token-saving flags: Many tools support
compact,summary, andlimitflags. These provide a significant reduction in token overhead. Truncating tools returnlimitedandtotalAvailableflags. This informs agents about capped results.
See also: Performance-Tuning · Configuration · Tool-Filtering
Unlock autonomous database orchestration with an enterprise-grade MySQL MCP server. Featuring blazing-fast sandboxed Code Mode, uncompromising schema enforcement, and seamless ecosystem integrations to power secure, intelligent AI workflows.
- Installation
- Configuration
- Architecture
- HTTP Transport
- Tool Filtering
- Code Mode
- Tools
- Prompts
- Resources
- Observability & Telemetry