BlogMariaDB

MariaDB 11 Upgrade: Optimizer Changes From 10.x

Scott Sternloff

By Scott Sternloff, Senior Enterprise Architect

LinkedIn · Updated · 4 min read

MariaDB 11 Upgrade: Optimizer Changes From 10.x
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.

VariableDefaultScope
optimizer_disk_read_cost10.24engine
optimizer_row_copy_cost0.060866engine
optimizer_key_compare_cost0.011361engine
optimizer_scan_setup_cost10session
optimizer_where_cost0.032session

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_tablespaces default went from 0 to 3, and histogram_type from DOUBLE_PREC_HB to JSON_HB.
  • The InnoDB change buffer and its settings were removed.
  • innodb_defragment*, innodb_file_per_table, innodb_flush_method and log_slow_admin_statements are deprecated.
  • Some optimizer_switch flags moved: hash_join_cardinality is on from 11.0.2, and engine_condition_pushdown is off by default and was removed in 11.3. The flag table and the defaults rows on the documentation page disagree for hash_join_cardinality, so read the live value with SELECT @@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?

  1. Collect candidates. Take the slowest queries from the slow query log. log_slow_verbosity can add query_plan and explain output (engine from 10.6.15).
  2. Refresh statistics on the copy. ANALYZE TABLE t PERSISTENT FOR ALL collects engine-independent statistics in mysql.table_stats, column_stats and index_stats.
  3. Run ANALYZE FORMAT=JSON on both versions. It executes the query and reports r_loops, r_rows, r_filtered and r_total_time_ms, and for InnoDB r_engine_stats with pages read.
  4. Compare actual against estimated rows. A large gap points at stale statistics, not a cost model problem.
  5. Use the optimizer trace for the rest: SET optimizer_trace='enabled=on' and read INFORMATION_SCHEMA.OPTIMIZER_TRACE.
  6. 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

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.

Scott Sternloff

Author

Scott SternloffSenior Enterprise Architect

Senior Enterprise Architect at AceMQ. Writes the technical coverage here: RabbitMQ, Kafka and Redis architecture, clustering and migrations.

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.

Free Consultation

Get Expert Eyes on Your MariaDB Environment

Whether you're troubleshooting a production incident, planning a migration, or want a second opinion on your architecture — our team is ready. No pitch, just answers.

Email Us