-
Notifications
You must be signed in to change notification settings - Fork 2
Capacity Planning
Value Proposition Achieve reliable multi-agent concurrency through optimized connection pooling, efficient schema caching, and tailored payloads that support high throughput. 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.
Tip
Set --pool-size to 2× the expected concurrent AI tool calls. For a single-agent setup, the default of 10 provides ample headroom.
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=300000As AI agents modify data, InnoDB tables may accumulate fragmentation. Regular maintenance workflows help preserve throughput.
Because InnoDB does not automatically reclaim disk space from deleted rows, optimize your storage footprint by using OPTIMIZE TABLE to seamlessly rebuild tables and indexes, effectively defragmenting your data files.
- When to use: After large bulk deletes, archival operations, or significant churn.
-
How: Use the
mysql_write_querytool to executeOPTIMIZE TABLE. -
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_write_querytool to executeANALYZE TABLE. -
Note: For MySQL, consider using histogram statistics. Use
ANALYZE TABLE ... UPDATE HISTOGRAM ON .... Do this for columns with skewed distributions.
Consider range partitioning for exceptionally large tables or time-series segments. Use the mysql_write_query tool to manage them. Benefits:
- Partition pruning reduces scan scope for time-bounded queries.
-
ALTER TABLE ... DROP PARTITIONis instant. This is compared toDELETE FROM ... WHERE date < X.
The InnoDB buffer pool is MySQL's primary memory cache. Its size directly impacts query performance and supports enterprise-scale AI data operations.
-
Monitoring: Use
mysql_read_queryto query performance metrics. Inspect hit rates, dirty page ratios, and free buffers. -
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. Use
mysql_read_queryto review this metric.
Note
Administrators should use the pre-configured Grafana dashboard. This aids ongoing capacity planning. It visualizes buffer pool stats. This reduces constant manual polling.
- Cost Optimization: Transmitting raw query results to LLMs incurs scaling limits and cost bottlenecks. Code Mode addresses this by aggregating data server-side to reduce context size and token consumption.
-
Default limit: Granular tool-level arguments efficiently enforce row limits on read queries, delivering precise control over context windows without relying on restrictive global server defaults. Code Mode strictly enforces a global payload boundary (
CODE_MODE_MAX_RESULT_SIZE). - Cursor pagination: Leverage keyset-based cursor pagination for scanning large tables instead of traditional OFFSET, which inefficiently forces MySQL to scan and discard rows. Cursor pagination executes in optimal O(1) time on indexed columns, ensuring consistent performance regardless of table size.
-
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