Free audit

View Audit Scope
MariaDBQuery, InnoDB & thread pool optimization

MariaDB Performance Tuning & Query Optimization

JusDB provides MariaDB performance tuning services for slow queries, InnoDB buffer pool and I/O flushing bottlenecks, pool-of-threads scheduling, and Galera flow-control stalls. Database engineers inspect ANALYZE FORMAT=JSON execution plans, index statistics, and lock waits across MariaDB 10.6, 10.11, 11.4, and 12.3 LTS, delivering measured SQL and my.cnf changes.

The first 30-minute call covers your databases, current ownership, and required coverage. No production access is needed. Or request a free audit of one database instance.

  • NDA before access
  • Read-only by default
  • Written scope before work starts

MariaDB tuning layers

Select a stack layer

ANALYZE FORMAT=JSON & 11.x cost model

Execution plan

Compare estimated rows against actual r_rows and r_time_ms in MariaDB ANALYZE FORMAT=JSON, tune optimizer_switch flags, and collect persistent histograms.

Fixes plan regressions after upgrading from MariaDB 10.x to 11.4 or 12.3 LTS.

See sample ANALYZE deliverable

Diagnostics use native ANALYZE FORMAT=JSON, performance_schema, and information_schema telemetry.

Focus areas
Slow SQL digests, composite indexes, 11.x optimizer histograms, pool-of-threads, and InnoDB I/O flushing
Change execution
Rehearsed on a replica first, then rolled out via ALGORITHM=INSTANT or throttled pt-online-schema-change
Urgent incident cover
Scoped tuning audit, or 24/7 support with a 15 mins P1 response SLA. See details

Selected clients

  • Innoviti
  • Blitz
  • Freecharge
  • Nango
  • Recochain
  • Screen Facts
  • Nexora
  • WeCredit

When teams call us

MariaDB performance bottlenecks we diagnose and fix

We trace CPU spikes, p99 latency jumps, and Galera stalls back to the exact execution plan, InnoDB flushing threshold, or thread scheduler setting causing them.

Common MariaDB performance symptoms, what is usually happening, and where JusDB engineers start
SymptomWhat is usually happeningWhere we start
r_rows >> rowsOptimizer picks a full table scan or wrong join order on skewed dataIndex cardinality estimates assume uniform value distribution; without engine-independent persistent histograms, the MariaDB 11.x cost model misjudges selectivity.Run ANALYZE FORMAT=JSON on the slow query, inspect r_rows vs rows and r_filtered, collect ANALYZE TABLE ... PERSISTENT FOR ALL, and add covering composite indexes.
Checkpoint age stallPeriodic write freezes every few minutes while disk IOPS is below maxinnodb_io_capacity is left at 200 on fast NVMe storage or innodb_log_file_size is undersized, forcing synchronous furious flushing when dirty pages hit the high watermark.Monitor innodb_checkpoint_age and buffer_pool_pages_dirty, size innodb_log_file_size for 1 hour of peak writes, and match innodb_io_capacity to real disk throughput.
Created_tmp_disk_tablesGROUP BY and ORDER BY queries spike temporary disk I/OQueries select TEXT/BLOB columns, exceed tmp_table_size / max_heap_table_size, or overflow aria_pagecache_buffer_size during internal temporary table creation.Rewrite projections to exclude unused BLOBs, add composite indexes that satisfy GROUP BY / ORDER BY in index order, and size aria_pagecache_buffer_size.
Threads_running spikeCPU hits 95%+ in system/kernel time during connection burststhread_handling=one-thread-per-connection spawns thousands of OS pthreads that contend on InnoDB mutexes and CPU caches.Switch to thread_handling=pool-of-threads, set thread_pool_size to vCPU count, tune thread_pool_stall_limit, and reserve extra_port for administration.
Metadata & row lock waitsApplication p99 latency jumps during background jobs or deploysUnindexed UPDATE/DELETE statements lock wide index gaps, or unbatched purge jobs hold row locks and undo history across millions of rows.Inspect SHOW ENGINE INNODB STATUS and information_schema.INNODB_LOCK_WAITS, add supporting indexes, and refactor batch jobs into primary-key chunks.
Galera certification abortsDeadlock errors (ERROR 1213) spike on multi-node Galera clustersApplication pools write to all Galera nodes concurrently on overlapping hot tables, triggering optimistic certification conflicts at commit time.Check wsrep_local_cert_failures and wsrep_local_bf_aborts, route writes to a single primary via MaxScale readwritesplit, and size wsrep_slave_threads.

Methodology and escalation

How a MariaDB performance tuning engagement works

We measure baseline metrics first, test changes on a replica, and verify every improvement. 24/7 support. SLA response times: P1 – 15 mins | P2 – 30 mins | P3 – 60 mins.

Four-step MariaDB performance tuning workflow

  1. Baseline

    Capture query digests, wait states, and my.cnf

    Read-only collection of pt-query-digest, InnoDB metrics, index statistics, and disk stall counters.

  2. Analyze

    Compare ANALYZE FORMAT=JSON plans on staging

    Isolate row-estimate skew, temporary disk spills, gap lock contention, and checkpoint stalls.

  3. Tune

    Apply online indexes, histograms, and config diffs

    Roll out non-blocking DDL, persistent statistics, pool-of-threads, and InnoDB flushing changes.

  4. Measure

    Written before-and-after latency & CPU report

    Compare p95/p99 query latency, buffer pool hit rate, and CPU utilization against your baseline.

SLA response times for active performance incidents

  • 15 mins

    P1 · Critical

    P1 incidents

  • 30 mins

    P2 · High

    P2 incidents

  • 60 mins

    P3 · Medium

    P3 incidents

SeverityResponse SLADefinitionChannel & coverage
P1 · Critical15 minsProduction database down, primary unreachable, data corruption risk, or active failover event.24/7 · Direct PagerDuty, Opsgenie, or phone page plus incident bridge
P2 · High30 minsSevere latency spike, replication lag climbing rapidly, connection exhaustion, or degraded HA node.24/7 · On-call alert plus shared Slack or Teams channel
P3 · Medium60 minsNon-critical slow query regression, staging issue, backup warning, configuration question, or planned operational request.24/7 · Shared Slack or Teams channel or support ticket

Our engineering team is in India (IST, UTC+5:30) and provides 24/7 support.

Response means an on-call engineer is working the incident, not an automated reply.

Scope of tuning

What does MariaDB performance tuning cover?

Our performance tuning scope spans slow query refactoring, composite index design, InnoDB buffer pool and flushing tuning, pool-of-threads concurrency, 11.x optimizer statistics, and Galera parallel appliers.

  • Slow query digest & plan refactoring

    We rank your query workload by total execution time and lock impact, then fix the top offenders at the SQL and index level.

    • pt-query-digest and performance_schema digest analysis
    • Line-by-line MariaDB ANALYZE FORMAT=JSON execution plan comparisons

    ANALYZE FORMAT=JSON · pt-query-digest · slow_query_log

  • Composite indexing & schema optimization

    Every index change is designed around B+Tree selectivity, sort avoidance, and write-amplification trade-offs.

    • Covering indexes that satisfy WHERE, JOIN, and ORDER BY without filesorts
    • Pruning unused and duplicate prefix indexes via userstat=1 telemetry

    userstat=1 · INDEX_STATISTICS · ALGORITHM=INSTANT · pt-osc

    MariaDB remote DBA operations
  • InnoDB buffer pool & I/O flushing tuning

    We align memory allocation and background flushing parameters with your dataset size and storage IOPS profile.

    • Sizing innodb_buffer_pool_size, innodb_log_file_size, and change buffering
    • Tuning innodb_io_capacity, innodb_max_dirty_pages_pct_lwm, and O_DIRECT

    innodb_metrics · SHOW ENGINE INNODB STATUS · iostat / CloudWatch

  • Thread pool & connection multiplexing

    Keep MariaDB responsive under thousands of concurrent application connections without CPU context-switch storms.

    • Configuring thread_handling=pool-of-threads and thread_pool_stall_limit
    • MaxScale or ProxySQL connection pooling and extra_port emergency access

    pool-of-threads · extra_port · MariaDB MaxScale · ProxySQL

    MariaDB MaxScale routing
  • MariaDB 11.x optimizer & histogram tuning

    Prevent query plan flips during upgrades to MariaDB 10.11, 11.4, or 12.3 LTS by tuning statistics and optimizer switches.

    • Engine-independent persistent statistics (ANALYZE TABLE ... PERSISTENT FOR ALL)
    • Targeted optimizer_switch adjustments for subquery materialization and join order

    mysql.column_stats · optimizer_switch · rowid_filter

    MariaDB LTS upgrade planning
  • Galera wsrep & GTID parallel replication

    Eliminate cluster flow-control stalls and replica lag during peak write bursts and nightly batch jobs.

    • Sizing wsrep_slave_threads against wsrep_cert_deps_distance
    • Tuning slave_parallel_threads and slave_parallel_mode=optimistic

    wsrep_provider_options · gcs.fc_limit · gtid_slave_pos

    MariaDB Galera Cluster tuning

Optimization progression and written evidence

How SQL and my.cnf tuning stabilize p95 latency

Hardware upgrades rarely fix an unindexed filesort or a saturated one-thread-per-connection scheduler. We fix the query plan first, then tune the engine.

Three stages of a MariaDB performance tuning engagement

Select a stage to inspect scheduler, optimizer, and InnoDB behavior.

Application concurrency and MariaDB execution engine

1,600 direct app connections hit one-thread-per-connection while unindexed joins spill to Aria disk temp tables.

p95 640ms · CPU 88% · Disk sorts
  • Thread Scheduler

    one-thread-per-connection with 1,600 active clients

    Threads_running=142 · High sys CPU

  • Query Optimizer

    Missing composite index + stale table statistics

    Using temporary; Using filesort

  • InnoDB Flushing

    Default innodb_io_capacity=200 on 16,000 IOPS NVMe

    Sync checkpoint stalls every 4m

Stock my.cnf settings throttle modern NVMe storage while unindexed sorting queries force Aria temporary tables onto disk.

Example written finding from a MariaDB tuning engagementSample deliverable

Finding

Thread-per-connection scheduler and Aria disk temp spills drove CPU to 91% at 1,400 connections

Enabling thread_handling=pool-of-threads, sizing aria_pagecache_buffer_size=2G, and replacing a two-column filesort with a composite index cut checkout p95 latency from 480 ms to 8.2 ms on the same 16-vCPU host.

Checkout p95 latency480ms → 8.2ms
Peak host CPU utilization91% → 26%

1. ANALYZE FORMAT=JSON check isolating temporary disk sort

ANALYZE FORMAT=JSON
SELECT o.id, o.merchant_id, o.amount_cents, o.created_at
FROM merchant_orders AS o
WHERE o.merchant_id = 48291 AND o.state IN ('PAID', 'SETTLED')
ORDER BY o.created_at DESC LIMIT 50;
-- Showed "r_rows": 194200, "r_total_time_ms": 462.8, "temporary_table": {"buffer_type": "disk"}

2. Thread pool, Aria cache, and InnoDB flushing profile in my.cnf

[mariadb]
thread_handling                = pool-of-threads
thread_pool_size               = 16
thread_pool_stall_limit        = 60
extra_port                     = 33062
aria_pagecache_buffer_size     = 2G
innodb_buffer_pool_size        = 48G
innodb_log_file_size           = 8G
innodb_io_capacity             = 4000
innodb_max_dirty_pages_pct_lwm = 10

Your team and ours

What managed MariaDB cloud services still leave to your team

Managed cloud databases automate much of the infrastructure layer, but your team still owns query performance, capacity, cost, and incident decisions.

Who handles each part of tuning MariaDB on a managed cloud service versus your own servers
AreaManaged cloud (Amazon RDS, SkySQL)Your own Linux VMs or Kubernetes
Cloud instance class, EBS gp3/io2 volumes, and networkAmazon RDS or cloud provider provisions the virtual hardware.Your platform team, right-sized using JusDB's IOPS and memory benchmarks.
Slow query analysis (ANALYZE FORMAT=JSON) and query rewritesYours. Cloud providers expose slow logs, but they do not rewrite SQL or design composite indexes.Analyzed, benchmarked, and delivered by JusDB engineers.
InnoDB flushing, redo log sizing, and Aria temp buffersRDS parameter groups use conservative defaults that often bottleneck high-throughput workloads.Tuned by JusDB to match your exact RAM, NVMe IOPS, and write rate.
Thread pool (pool-of-threads) and connection multiplexingRequires parameter group tuning and external proxy sizing to prevent connection storms.Configured end to end with pool-of-threads, extra_port, and MaxScale.
MariaDB 11.4 / 12.3 LTS optimizer regression testingCloud upgrades swap binaries; preventing query plan regressions after upgrade is your team's job.JusDB replays production digests and configures persistent histograms before cutover.

Your team keeps control

  • Set business priorities, application requirements, and release plans
  • Approve production changes, except routine actions you have pre-approved
  • Own your cloud accounts, access policies, and vendor relationships
  • Decide when maintenance can happen and how quickly service must recover
  • Move the work in-house or to another provider after your agreement's notice period, with your data returned or deleted and the transition help your agreement sets out (Terms, section 8)

JusDB handles the agreed tuning work

  • Monitor database health, investigate alerts, and involve the right people
  • Review query performance, replication, capacity, and backup health
  • Carry out approved changes and update the operating instructions they affect
  • Report completed work, open risks, and recommended next steps

Where your MariaDB runs

Compare options

How JusDB MariaDB Performance Tuning compares with hardware scaling and automated tools

Compare a forensic JusDB MariaDB tuning engagement against throwing larger cloud instances at the problem, relying on automated config scripts, or leaving query tuning to app sprints.

Evaluation Vector
JusDB DBRE
In-House DBALegacy AgencyDeveloper Generalist
Thread Pool & Connection HandlingAdvanced enterprise thread pool calibration: threadpool_size pinned to CPU sockets, threadpool_stall_limit fine-tuned, and threadpool_oversubscribe optimized for 10,000+ connections with zero context thrashing.Uses standard one-thread-per-connection model, leading to OS scheduler thrash and severe CPU degradation as connection counts scale beyond 500.Blindly raises max_connections to absorb surges, risking catastrophic memory exhaustion and Linux OOM kernel termination.Relies on default ORM pool settings without database connection multiplexing, triggering frequent 'Too many connections' outages.
InnoDB Buffer Pool & Dirty Page FlushingScientific buffer pool right-sizing (70%–80% RAM), multi-instance segmenting, and dynamic innodb_max_dirty_pages_pct / innodb_io_capacity calibration to eradicate furious flushing stalls.Leaves default 128MB or static buffer pool size without dirty page flush tuning, triggering IO write spikes and unpredictable transaction freezing.Sets arbitrary large buffer pools without accounting for per-thread memory buffers, causing OS swap thrashing and disk IO collapse.Unaware of buffer pool mechanics, assuming low query performance is purely an SSD hardware throughput limitation.
Slow Query & Index OptimizationSystematic Performance Schema statement digest profiling, EXPLAIN ANALYZE execution plan diagnostics, composite covering index design, and filesort elimination.Reactive manual inspection of raw slow query logs without statistical aggregation, frequently missing high-frequency micro-latency queries.Adds redundant single-column indexes on every WHERE clause field, bloating index memory footprint and crippling write throughput.Tweaks application ORM queries with trial-and-error changes without analyzing MariaDB optimizer choices or index selectivity.
Temp Table & Aria Engine TuningCalibrates max_heap_table_size and tmp_table_size memory limits while tuning the Aria engine page cache (aria_pagecache_buffer_size) for lightning-fast disk-spilled internal sort operations.Overlooks Aria engine configuration, allowing internal implicit temporary tables to default to unoptimized disk writes during large GROUP BY and DISTINCT queries.Sets excessively large memory limits that exhaust global RAM during concurrent complex analytical joins.Pulls entire unindexed datasets into application memory to perform client-side filtering and sorting, overwhelming network bandwidth.
Galera Transaction Certification Latencywsrep_flow_control_paused forensics, certification queue depth minimization, optimistic lock contention mitigation, and multi-threaded slave applier optimization.Struggles with cluster-wide write hangs during Galera flow control events, unable to identify which slow node or long transaction triggered the stall.Reboots desynchronized Galera nodes blindly, causing full SST network floods that saturate cluster bandwidth and impact live traffic.Runs heavy batch write transactions that violate Galera limits, triggering cascade rollbacks and DEADLOCK errors across all app instances.
Replication Lag & Parallel ReplicationImplements multi-threaded parallel replication (slave_parallel_threads & slave_parallel_mode=optimistic), GTID domain routing, and MaxScale causal read consistency.Runs single-threaded replication prone to multi-hour slave lag during bulk ETL writes, leading to stale reads on read replicas.Configures basic asynchronous replication without transaction boundaries or crash-safe slave position verification.Reads directly from out-of-sync read replicas without replication lag checks, serving obsolete data to end users.

For procurement and security

NDA first, read-only by default, and written scope

We work alongside your engineering and platform teams. Your team approves every index or configuration change and keeps all benchmark scripts and reports.Raguraman, Head of DBSRE · Allen D, Principal Engineer
  • Mutual NDA
  • Written statement of work
  • Named engineers
  • Least-privilege access
  • NDA before access

    Signed before any diagnostic access. The initial scoping call needs no database credentials.

  • Written agreement

    Target MariaDB instances, deliverables, timeline, and fees agreed in writing before work starts.

  • Least-privilege accounts

    Named read-only accounts by default, accessed through your bastion or VPN with session logging.

  • Deliverables you keep

    Every ANALYZE FORMAT=JSON comparison, my.cnf profile, and online DDL script stays with your team. Meet the JusDB team.

JusDB's security practices are aligned with ISO 27001 and SOC 2 Type II, and JusDB is pursuing both certifications (see Terms, section 12). Read the stated status.

FAQ

Common MariaDB performance tuning questions

Answers on ANALYZE FORMAT=JSON, MariaDB 11.x optimizer changes, online index builds, pool-of-threads, and Amazon RDS tuning.

Still have a question?

Ask it on a scoping call. No production access needed.

Book a 30-min scoping call (opens Google Calendar in a new tab)

How do you diagnose slow MariaDB queries without adding load to production?

We analyze existing slow query logs with pt-query-digest, query performance_schema statement digests, and inspect information_schema.INDEX_STATISTICS and TABLE_STATISTICS. When we need to run ANALYZE FORMAT=JSON or test new indexes, we run them against a replica or staging snapshot first.

Why is MariaDB ANALYZE FORMAT=JSON better than standard EXPLAIN?

Standard EXPLAIN only shows the optimizer's estimates. MariaDB's ANALYZE FORMAT=JSON executes the statement and outputs side-by-side estimated rows versus actual r_rows, actual r_filtered percentages, r_time_ms per join tab, and filesort buffers, pinpointing exactly where the cost model diverged.

Can you fix query regressions after upgrading to MariaDB 10.11 or 11.4 LTS?

Yes. MariaDB 11.x introduced a new cost-based optimizer model that changes index scan vs table scan thresholds. We collect engine-independent persistent statistics (ANALYZE TABLE ... PERSISTENT FOR ALL), tune optimizer_switch flags, and add covering indexes so upgraded queries run faster than on 10.x.

How do you apply index changes on multi-hundred-gigabyte tables without locking writes?

We check whether the change qualifies for MariaDB's native ALGORITHM=INSTANT or ALGORITHM=INPLACE, LOCK=NONE. For changes that require a table rebuild, we execute pt-online-schema-change or gh-ost with strict replica-lag and Threads_running throttles.

What my.cnf parameters matter most for MariaDB InnoDB and thread performance?

The highest-leverage settings are innodb_buffer_pool_size, innodb_log_file_size, innodb_io_capacity, innodb_max_dirty_pages_pct_lwm, innodb_flush_method=O_DIRECT, aria_pagecache_buffer_size, and thread_handling=pool-of-threads with properly sized thread_pool_size.

Can you tune MariaDB on Amazon RDS where shell access is restricted?

Yes. On Amazon RDS for MariaDB, we tune DB Parameter Groups, analyze slow query logs via RDS APIs and Performance Schema, optimize schema and composite indexes, and right-size EBS gp3/io2 provisioned IOPS and instance classes.

What are your SLA response times if we have an active performance outage?

24/7 support. SLA response times: P1 – 15 mins | P2 – 30 mins | P3 – 60 mins. Our engineering team is in India (IST, UTC+5:30) and provides 24/7 support.

When should we choose MariaDB Performance Tuning versus Remote DBA or Support?

Choose MariaDB Performance Tuning when you want a focused engagement to eliminate slow queries, high CPU, lock contention, or Galera flow-control stalls. Choose MariaDB Remote DBA for ongoing weekly query curation and schema maintenance, or MariaDB Support for 24/7 incident escalation.

MariaDB playbooks and resources

MariaDB performance, Galera, and optimizer guides

Practical guides from our engineering team on MariaDB vs MySQL internals, Galera flow control, and wsrep tuning.

Next step

Talk to a MariaDB engineer about your query latency

Tell us which MariaDB versions, storage engines, and query bottlenecks you are seeing. The first 30-minute call covers your databases, current ownership, and required coverage. No production access is needed. Or request a free audit of one database instance, subject to availability: mutual NDA before read-only access, a prioritized report within one week after access is ready, and no obligation.

NDA before access · read-only by default · written scope first