MySQL Config Calculator

Enter your server's RAM, cores, connection count and workload and get a my.cnf tuned for it. The calculator sizes innodb_buffer_pool_size and its instance count, redo log capacity, the per-session sort and join buffers, I/O capacity for your storage type, and the table and thread caches — then adds up the worst case so you can see whether the configuration actually fits in memory. Output as a my.cnf block or as SET GLOBAL statements, with static variables called out separately. Everything is computed in your browser; nothing is uploaded.

What each setting does

InnoDB memory

  • innodb_buffer_pool_size = 11520M 70% of RAM. The single most important MySQL setting: it caches both data and index pages, so a working set that fits here is served without touching disk.
  • innodb_buffer_pool_instances = 8 Splits the pool into 8 independently latched regions (~1.4 GB each), reducing mutex contention on multi-core hosts.
  • innodb_buffer_pool_chunk_size = 128M Granularity of online buffer pool resizing. buffer_pool_size must be a multiple of chunk_size × instances or MySQL rounds it up silently.
  • tmp_table_size = 256M Maximum size of an internal in-memory temporary table before it spills to disk. Allocated per statement, not globally.
  • max_heap_table_size = 256M Must match tmp_table_size — MySQL uses the smaller of the two when deciding whether an internal temp table stays in memory.
  • sort_buffer_size = 2M Per-session buffer for ORDER BY and GROUP BY without an index. Large values hurt: the buffer is allocated in full for every sort.
  • join_buffer_size = 1M Per-join-of-a-kind buffer for joins that cannot use an index. Fix the missing index rather than raising this.
  • read_rnd_buffer_size = 512K Buffer used when reading rows in sorted order after a sort, per session.
  • read_buffer_size = 256K Per-session buffer for sequential table scans on MyISAM and for some internal operations.
  • max_allowed_packet = 64M Largest single packet or row the server accepts. Raise it if you store large BLOBs or run big multi-row INSERTs.

Redo log and durability

  • innodb_redo_log_capacity = 2880M Total redo log size (MySQL 8.0.30+). Bigger means fewer checkpoints and smoother write throughput, at the cost of longer crash recovery.
  • innodb_log_buffer_size = 32M In-memory staging area for redo records. Raise it if you run large transactions so they do not force a log flush mid-transaction.
  • innodb_flush_log_at_trx_commit = 1 1 = fsync on every commit. This is the only fully ACID-durable setting and the correct default for transactional workloads.
  • sync_binlog = 1 1 keeps the binary log in sync with InnoDB on every commit, which replication and point-in-time recovery depend on.
  • innodb_doublewrite = ON Protects against torn pages. Leave it on unless your storage guarantees atomic page writes.
  • innodb_file_per_table = ON One .ibd file per table, so DROP TABLE and OPTIMIZE TABLE actually return space to the filesystem.

Storage I/O

  • innodb_flush_method = O_DIRECT Bypasses the OS page cache for data files so pages are not cached twice. Use fsync on Windows or when running on ZFS.
  • innodb_io_capacity = 4000 Baseline IOPS budget for background flushing, sized for NVMe.
  • innodb_io_capacity_max = 12000 Ceiling InnoDB may use when it is falling behind on flushing. Keep it well under what the device can actually sustain.
  • innodb_flush_neighbors = 0 0 — on SSD/NVMe there is no seek penalty, so flushing neighbours just writes pages that were not dirty enough to need it.
  • innodb_read_io_threads = 4 Background threads for read-ahead and prefetch requests.
  • innodb_write_io_threads = 4 Background threads servicing write requests from the buffer pool.
  • innodb_page_cleaners = 8 Flush threads. Matching the buffer pool instance count lets each instance be cleaned in parallel.
  • innodb_adaptive_flushing = ON Adjusts the flush rate from the redo generation rate instead of flushing in bursts at checkpoint time.

Connections and caches

  • max_connections = 200 Hard cap on concurrent client connections. Each one costs memory and a thread — pool in the application rather than raising this.
  • thread_cache_size = 16 Threads kept alive for reuse after a client disconnects, avoiding thread-creation cost on churny connection patterns.
  • table_open_cache = 2000 Open table handles cached across sessions, sized for roughly 500 tables.
  • table_definition_cache = 1400 Cached .frm/data-dictionary definitions. Too low and MySQL re-reads table metadata constantly.
  • open_files_limit = 65535 File descriptor ceiling. The OS limit (LimitNOFILE in systemd) must be at least this high or MySQL silently caps itself.
  • innodb_thread_concurrency = 0 0 = let InnoDB manage concurrency itself. Only set a limit if you have measured thrashing above a specific thread count.
  • innodb_lock_wait_timeout = 20 Seconds a transaction waits for a row lock before rolling back its statement. Short timeouts surface lock contention as errors instead of stalls.

Observability

  • slow_query_log = ON You cannot tune what you cannot see. The slow log is the cheapest source of truth about which statements actually hurt.
  • slow_query_log_file = /var/log/mysql/slow.log Point this at a path the mysql user can write and that is rotated.
  • long_query_time = 1 Threshold in seconds. Start here, then lower it once the obvious offenders are fixed.
  • log_queries_not_using_indexes = OFF Leave off in production: small lookup tables legitimately full-scan and will flood the log.
  • innodb_stats_persistent = ON Keeps index statistics across restarts so the optimizer does not re-plan differently after every bounce.
  • innodb_stats_persistent_sample_pages = 20 Pages sampled when recomputing statistics. Higher is more accurate and slower to collect.
  • performance_schema = ON Costs a few percent of throughput and is the only way to get statement and wait instrumentation. Keep it on.
  • binlog_expire_logs_seconds = 604800 Seven days of binary logs — enough for point-in-time recovery without filling the disk.

Character set

  • character_set_server = utf8mb4 Real 4-byte UTF-8. The legacy utf8 alias stores only 3 bytes and cannot hold emoji or many CJK characters.
  • collation_server = utf8mb4_0900_ai_ci MySQL 8's default Unicode 9.0 collation. Use utf8mb4_bin only if you need byte-exact comparison.

Do more than mysql config calculator — meet Chat2DB

Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.

How to use

  1. Enter the server's RAM, vCPU count and how many tables the instance holds, then pick the workload that matches your database.
  2. Set max_connections to what your application pool actually opens, and choose your storage type so the I/O capacity values match the device.
  3. Copy the result into /etc/mysql/my.cnf (or a file under conf.d), restart MySQL, and check the memory budget panel before rolling it out.

Frequently asked questions

How big should innodb_buffer_pool_size be?

On a dedicated database server, 70% of RAM is the usual starting point, which is what this calculator uses above 8 GB. The buffer pool caches both data and index pages, so the goal is for your working set — not your whole database — to fit inside it. On a host shared with an application server, drop to roughly 45% and leave the rest for everything else. Whatever you choose, make it a multiple of innodb_buffer_pool_chunk_size × innodb_buffer_pool_instances, or InnoDB will round the value up without telling you.

Why are sort_buffer_size and join_buffer_size so small?

They are per-session allocations, not a shared pool. MySQL allocates the full sort_buffer_size for every sort that cannot use an index, and join_buffer_size for every join that has no usable index — so with 500 connections an 8 MB sort buffer is a potential 4 GB of memory. Large values also make small sorts slower, because MySQL has to initialise the whole buffer. If a query needs a big sort buffer to perform, the real fix is almost always an index.

Do I need to restart MySQL after changing my.cnf?

Some settings only. innodb_buffer_pool_instances, innodb_log_file_size, innodb_flush_method, the I/O thread counts, performance_schema and the character set defaults are static and need a restart. innodb_buffer_pool_size, innodb_io_capacity, max_connections, the session buffers and the slow log settings are dynamic and can be changed with SET GLOBAL — switch the output format above to generate those statements. Note that SET GLOBAL does not survive a restart, so write the values into my.cnf as well. To inspect the running values and compare them across servers, connect with Chat2DB at https://chat2db.ai/download or https://app.chat2db.ai.

More free SQL tools

SQL Formatter & Beautifier
Format and beautify SQL queries online with dialect-aware indentation and keyword casing.
SQL Validator & Syntax Checker
Check SQL syntax online for MySQL, PostgreSQL and more, with clear error messages.
SQL Minifier
Minify SQL by stripping comments and collapsing whitespace into a single line.
MySQL to PostgreSQL Converter
Convert MySQL DDL and queries to PostgreSQL syntax with a best-effort dialect translator.
CSV to SQL Converter
Turn CSV, TSV or pasted Excel data into SQL INSERT statements.
JSON to SQL Converter
Convert a JSON array of objects into SQL INSERT statements.
SQL IN Clause Generator
Paste a list of values and get a ready-to-use SQL IN (...) clause.
SQL Escape & Unescape
Escape single quotes and special characters for safe SQL string literals.
JDBC Connection String Builder
Build JDBC URLs for MySQL, PostgreSQL, SQL Server, Oracle, MariaDB and ClickHouse.
SQL Cheat Sheet
A practical SQL reference: joins, aggregation, window functions, DDL and dialect differences.
UUID Generator (v4 & v7)
Generate UUID v4 and time-ordered UUID v7 in bulk, as plain text, JSON, CSV or SQL.
Cron Expression Generator & Validator
Build and validate cron expressions with plain-English explanations and next run times.
PostgreSQL EXPLAIN Plan Visualizer
Turn EXPLAIN ANALYZE output into a readable plan tree with timings and tuning warnings.
PgBouncer Config Generator
Generate pgbouncer.ini and size connection pools from your app instances and CPU cores.
PostgreSQL Partition Table Generator
Generate RANGE, LIST and HASH partitioning DDL with child partitions and maintenance SQL.
pg_dump Command Generator
Build pg_dump and pg_restore commands with format, filter and parallel job options.
mysqldump Command Generator
Build mysqldump backup commands with scope, options and a matching restore command.
SQL Test Data Generator
Generate realistic fake rows as SQL INSERT statements, CSV or JSON, right in your browser.
PostgreSQL Config Calculator
Calculate tuned postgresql.conf settings from your RAM, CPU cores, connections and workload.
SQL DDL to Code Generator
Convert CREATE TABLE statements into TypeScript, Prisma, Drizzle, Go, JPA or SQLAlchemy models.
SQL Window Function Generator
Build ROW_NUMBER, RANK, LAG, LEAD and running-total OVER() clauses with PARTITION BY and frames.
Docker Compose PostgreSQL Generator
Generate a docker-compose.yml for PostgreSQL with volumes, healthchecks, init scripts and pgAdmin.
PostgreSQL Replication Config Generator
Generate streaming and logical replication config: postgresql.conf, pg_hba.conf, slots and pg_basebackup.
SQL Injection Checker
Scan code for SQL injection risks and rewrite unsafe queries with bound parameters.
SQL to ER Diagram Generator
Paste CREATE TABLE DDL and get an entity relationship diagram plus Mermaid erDiagram code.
Postgres Connection String Generator
Build PostgreSQL connection strings: libpq URI, DSN, JDBC, psycopg, SQLAlchemy, Npgsql and .env.
Postgres GRANT Statement Generator
Generate PostgreSQL GRANT, ALTER DEFAULT PRIVILEGES and REVOKE scripts for read-only or read-write roles.
Postgres COPY Command Generator
Build PostgreSQL COPY and psql \copy commands to import or export CSV with HEADER, DELIMITER, NULL and WHERE options.
Postgres CREATE INDEX Generator
Generate PostgreSQL CREATE INDEX statements: B-tree, GIN, GiST, BRIN, UNIQUE, CONCURRENTLY, partial WHERE, INCLUDE and expression indexes.
Postgres TO_CHAR Date Format Builder
Build PostgreSQL TO_CHAR date format patterns with live preview, presets and generated TO_CHAR / TO_TIMESTAMP statements.
Postgres FDW Setup Generator
Generate postgres_fdw CREATE SERVER, USER MAPPING and IMPORT FOREIGN SCHEMA SQL for querying a remote Postgres database.
Postgres EXCLUDE Constraint Generator
Generate PostgreSQL EXCLUDE constraint SQL: GiST/SP-GiST operators, btree_gist columns, partial WHERE and overlap-check verification.
pgvector Index & Schema Generator
Generate pgvector SQL: vector/halfvec columns, HNSW or IVFFlat indexes, tuned parameters and the matching nearest-neighbour query.
Postgres ALTER COLUMN TYPE Generator
Generate ALTER TABLE ALTER COLUMN TYPE SQL with the right USING cast, a table-rewrite verdict and a batched zero-downtime migration.
Postgres UPSERT Generator
Build INSERT ... ON CONFLICT DO UPDATE/DO NOTHING statements, the MERGE equivalent and the unique index they need.
pg_hba.conf Generator
Generate PostgreSQL client authentication rules with the right connection type, CIDR and auth method.
Postgres Trigger Generator
Generate CREATE TRIGGER SQL and plpgsql trigger functions: updated_at touch, JSONB audit log, operation guards and TG_OP skeletons.
Postgres VACUUM Command Generator
Build VACUUM / VACUUM FULL / ANALYZE commands with the right options, plus monitoring SQL and per-table autovacuum tuning.
SQL Pivot Generator (Rows to Columns)
Generate pivot queries with FILTER or CASE WHEN aggregates, the PostgreSQL crosstab() version and the reverse unpivot.
Epoch & Unix Timestamp Converter
Convert epoch to date and back with auto unit detection, plus to_timestamp and extract(epoch) SQL snippets.
pg_restore Command Generator
Build pg_restore or psql restore commands from a Postgres dump: archive format, parallel jobs, clean, no-owner and single-transaction options.
Postgres JSONB Query Builder
Generate JSONB queries from a nested path and operator, with the matching GIN or expression index and a JSONB cookbook.
SQL Schema Diff & Migration Generator
Compare two SQL schemas and generate the ALTER TABLE up and down migration, with lock and rewrite warnings.
Postgres Table Size Estimator
Estimate table and index size from your columns and row count, including tuple header, alignment padding and column-order savings.
Postgres Full Text Search Generator
Generate tsvector columns, GIN indexes, weighted ranking and ts_headline queries for PostgreSQL full text search.
Levenshtein Distance Calculator
Compute edit distance between two strings with the full DP matrix, edit path and matching Postgres fuzzy search SQL.
SQL Linter & Style Checker
Lint SQL for correctness traps, non-sargable predicates and style issues in your browser.
Database Normalization Analyzer
Find candidate keys and 1NF/2NF/3NF/BCNF violations, then get a lossless decomposition.
Connection Pool Size Calculator
Size your database connection pool from cores, latency and instances, with HikariCP, pgxpool, node-pg, SQLAlchemy and PgBouncer config.
PostgreSQL Error Code Lookup
Look up any SQLSTATE code or paste an error message to get the cause, the fix and how to catch it in your driver.
Postgres Autovacuum Calculator
Work out when autovacuum fires on a table, how much bloat builds up first, and generate per-table ALTER TABLE tuning.
SQL to MongoDB Query Converter
Convert a SQL SELECT into a MongoDB find() call or aggregation pipeline, with $lookup, $group, $match and $sort mapping.
pgloader Config Generator
Build a pgloader .load file to migrate MySQL, SQL Server, SQLite or CSV into PostgreSQL, with cast rules, table filters and verification SQL.
Postgres Upgrade Planner
Compare pg_upgrade, dump/restore and logical replication for a major version upgrade, with downtime estimates, commands and breaking changes.
SQL Join Visualizer
See INNER, LEFT, RIGHT, FULL, CROSS and anti joins run on real sample rows, with the SQL.
SCD Type 2 SQL Generator
Generate slowly changing dimension Type 2 DDL and load SQL for Postgres, Snowflake and BigQuery.
Postgres RLS Policy Generator
Generate PostgreSQL row level security policies for multi-tenant, per-user or role-based access.
Postgres Data Masking Generator
Build masked views, anonymization UPDATEs or PostgreSQL Anonymizer labels for sensitive columns.
Online SQL Playground
Run SQL in your browser against a sample SQLite database, with 10 checked practice exercises.
SQL CASE WHEN Generator
Build searched or simple CASE expressions with full queries and IF/IIF/DECODE equivalents per dialect.
SQL Set Operations Visualizer
See UNION, UNION ALL, INTERSECT and EXCEPT run on real rows, with counts and SQL per dialect.
Postgres Enum Type Generator
Generate CREATE TYPE, ADD VALUE, RENAME VALUE, safe value removal and enum-to-CHECK or lookup migrations.
Postgres Lock Conflict Checker
Check whether two PostgreSQL statements or LOCK TABLE modes block each other, with the conflict matrix and pg_locks queries.
Postgres Timezone Converter
Convert timestamps between IANA zones and generate AT TIME ZONE, SET timezone and date_trunc SQL with DST warnings.
Slow Query Log Analyzer
Group a MySQL or PostgreSQL slow query log by normalized query shape and rank the shapes by total time.
Postgres generate_series Builder
Build generate_series SQL for calendar tables, time buckets, gap-filled reports and test data, with a row preview.
Postgres Index Type Advisor
Pick between B-tree, Hash, GIN, GiST, SP-GiST, BRIN and HNSW for a column and query pattern, with the CREATE INDEX statement and operator class.
Postgres SERIAL to IDENTITY Converter
Convert a SERIAL or BIGSERIAL column to GENERATED AS IDENTITY with the correct setval, rollback and optional bigint widening.
Postgres DROP ROLE Helper
Generate the audit queries, REASSIGN OWNED, DROP OWNED and DROP ROLE script that clears "role cannot be dropped" errors.
pg_stat_statements Query Builder
Build version-correct Top-N pg_stat_statements queries by total time, mean time, calls, cache misses, temp spills or WAL.
AWS DMS Table Mapping Generator
Build a valid AWS DMS table-mappings.json with selection rules, schema and table renames, column removal and source row filters.
ClickHouse MergeTree Table Generator
Generate ClickHouse CREATE TABLE DDL with MergeTree engines, sorting keys, partitioning, TTL and compression codecs.
SQL Server to PostgreSQL Converter
Translate T-SQL DDL and queries to PostgreSQL: brackets, IDENTITY, NVARCHAR, TOP, GETDATE and more.
Docker Compose MySQL & MariaDB Generator
Generate docker-compose.yml for MySQL or MariaDB with volumes, healthchecks, init scripts and phpMyAdmin.
Oracle to PostgreSQL Converter
Translate Oracle DDL and SQL to PostgreSQL: VARCHAR2, NUMBER, NVL, DECODE, SYSDATE, sequences and more.
SQL Server Backup & Restore Command Generator
Generate T-SQL BACKUP and RESTORE scripts with compression, checksum, WITH MOVE, STOPAT and sqlcmd.
pgbench Command Generator
Build pgbench init and benchmark command lines for PostgreSQL load testing.
dbt schema.yml Generator
Turn a CREATE TABLE statement into a dbt schema.yml with data tests and a unit test skeleton.
DBML to SQL Converter
Convert DBML schemas to PostgreSQL or MySQL DDL, and turn existing CREATE TABLE statements back into DBML.
Liquibase Changelog Generator
Turn SQL DDL into a Liquibase changelog in XML, YAML, JSON or formatted SQL, with constraints and rollbacks.
Debezium Connector Config Generator
Build a Debezium CDC connector config for PostgreSQL, MySQL, SQL Server, Oracle or MongoDB.
MongoDB Connection String Builder
Build or parse mongodb:// and mongodb+srv:// URIs with encoded passwords, auth and replica set options.
MySQL GRANT Statement Generator
Generate MySQL 8 CREATE USER, GRANT, role and REVOKE scripts for read-only, read-write or replication users.
OtterMind
OtterMind