On this page
Short answer
MariaDB 11.0 introduced a new optimizer cost model, so some query plans change after an upgrade from 10.x. Most should improve, but a few will not. Capture your slowest queries with ANALYZE FORMAT=JSON on the old and new servers, compare r_rows and r_total_time_ms, and refresh statistics before you judge a plan.
MariaDB 11.0 introduced a new optimizer cost model, so some query plans change after an upgrade from 10.x. Most should get better, and a few will not. The safe route is to capture your slowest queries with ANALYZE FORMAT=JSON on the old and new servers, compare real rows and times, and refresh statistics before you judge a plan. Facts are from the MariaDB Knowledge Base, read 3 December 2026.
Our mariadb consulting engineers run this comparison as part of upgrade planning, and the same steps work for an in-house team.
What did the 11.0 optimizer cost model change?
In MariaDB 11.0 the query optimizer chooses a query plan by estimating the cost of each option, and the new cost model changes those estimates. It now uses a base engine cost of 1 ms, with user-visible costs shown in microseconds. Cost variables can be set per storage engine, and engine values take effect on tables opened after the change, so run FLUSH TABLES. The documentation lists plans that should improve: joins of more than two tables, indexes with many duplicate values, ranges covering more than 10 percent of a table, mixed storage engines, derived tables and subqueries, ORDER BY or GROUP BY satisfied by an index, and queries that previously needed FORCE INDEX.
It also warns that some plans change, that ANALYZE TABLE may worsen some plans, and that EXPLAIN no longer shows Using index for scans of a clustered primary key.
| Variable | Default | Scope |
|---|---|---|
optimizer_disk_read_cost | 10.24 | engine |
optimizer_row_copy_cost | 0.060866 | engine |
optimizer_key_compare_cost | 0.011361 | engine |
optimizer_scan_setup_cost | 10 | session |
optimizer_where_cost | 0.032 | session |
These are the documented defaults, and InnoDB overrides some of the engine costs. The disk read cost assumes a mid-range SSD at 400 MB a second, so slow or very fast storage is the first place to check if plans look odd.
What else changes in the 11.0 upgrade?
innodb_undo_tablespacesdefault went from 0 to 3, andhistogram_typefromDOUBLE_PREC_HBtoJSON_HB.- The InnoDB change buffer and its settings were removed.
innodb_defragment*,innodb_file_per_table,innodb_flush_methodandlog_slow_admin_statementsare deprecated.- Some
optimizer_switchflags moved:hash_join_cardinalityis on from 11.0.2, andengine_condition_pushdownis off by default and was removed in 11.3. The flag table and the defaults rows on the documentation page disagree forhash_join_cardinality, so read the live value withSELECT @@optimizer_switch. - After the binaries change, run
mariadb-upgrade, as the MariaDB documentation says for upgrading MariaDB between major versions. Plan the order for any replication topology and take a backup first.
How do you test plans before you upgrade?
- Collect candidates. Take the slowest queries from the slow query log.
log_slow_verbositycan addquery_planandexplainoutput (enginefrom 10.6.15). - Refresh statistics on the copy.
ANALYZE TABLE t PERSISTENT FOR ALLcollects engine-independent statistics inmysql.table_stats,column_statsandindex_stats. - Run
ANALYZE FORMAT=JSONon both versions. It executes the query and reportsr_loops,r_rows,r_filteredandr_total_time_ms, and for InnoDBr_engine_statswith pages read. - Compare actual against estimated rows. A large gap points at stale statistics, not a cost model problem.
- Use the optimizer trace for the rest:
SET optimizer_trace='enabled=on'and readINFORMATION_SCHEMA.OPTIMIZER_TRACE. - Decide per query. Adjust the statistics or an
optimizer_*cost before reaching for hints.
Which version should you move to: 10.11, 11.4 or 11.8?
Read the release notes and the upgrading page for the exact target first. MariaDB 11.0 was a short-term major version, so a 10.x estate normally lands on a long-term support release. The MariaDB maintenance policy lists 10.11 with community end of life on 16 February 2028, 11.4 on 29 May 2029 and 11.8 on 4 June 2028. Check the page again before you plan, because dates move.
Pair this with a written plan: see our MariaDB 10 to 11 upgrade use case and the MariaDB end of life guide.
Sources
- The optimizer cost model from MariaDB 11.0, MariaDB Knowledge Base, read 3 December 2026.
- Upgrading from MariaDB 10.11 to 11.0 and What is MariaDB 11.0, MariaDB Knowledge Base, read 3 December 2026.
- optimizer_switch, ANALYZE FORMAT=JSON and Optimizer trace overview, MariaDB Knowledge Base, read 3 December 2026.
- Engine-independent table statistics and Slow query log extended statistics, MariaDB Knowledge Base, read 3 December 2026.
- Maintenance policy, mariadb.org, read 3 December 2026.
Frequently Asked Questions
Does MariaDB 11 change query plans?
Yes. MariaDB 11.0 introduced a new optimizer cost model, and the documentation warns that some plans change and that ANALYZE TABLE may make some plans worse. Test your slowest queries on a copy before the upgrade.
How do I compare plans before and after a MariaDB upgrade?
Run ANALYZE FORMAT=JSON on the same queries on both servers, with comparable data and statistics. Compare r_rows, r_filtered and r_total_time_ms, not only the estimated rows.
Which MariaDB 11 version should I upgrade to?
11.0 was a short-term series that has ended, so most 10.x estates target an LTS release. MariaDB's maintenance policy lists 11.4 and 11.8 as long-term support releases.
Talk to an engineer
Need a hand with MariaDB?
Senior engineers who run it in production. Get a quote or a free consultation, no sales pitch.

