MariaDB Server 13.0 Adds MySQL-Style Optimizer Hints, Including Hints Inside Views

MariaDB 13.0 brings a full set of per-query optimizer hints with MySQL's syntax, and goes further by allowing hints in views and path-based query block names.

MariaDB has explained the new optimizer hints that ship with MariaDB Server 13.0. In a guest post on the MariaDB.org blog dated 9 November 2026, senior engineer Oleg Smirnov describes a broad set of per-query hints that let developers steer the query planner when they know something it does not.

The hints use the same comment syntax that MySQL introduced in version 8.0, so teams moving between the two systems can reuse what they already know. MariaDB also goes beyond MySQL in two places: where hints may be placed in views, and how a hint can point at a specific query block.

What MariaDB Server 13.0 Changes

Earlier MariaDB versions offered only older-style index hints. Version 13.0 adds new-style hints written inside a special comment placed right after the SELECT keyword. Each hint takes arguments, and several hints can be combined in a single comment.

The same comment can also appear in a subquery, which allows a different hint for each part of a statement. The post notes that TiDB, another MySQL-compatible database, adopted the same syntax.

What the Hints Control

According to the announcement, the hints let a user influence several kinds of planner decisions for a single statement:

  • The order in which tables are joined.
  • Which indexes are used or ignored.
  • Whether join buffers are used.
  • Whether derived tables are merged.
  • Whether conditions are pushed down into derived tables.
  • Which strategy runs a subquery.
  • Optimizations such as MRR, index condition pushdown, range optimization, rowid filtering and lateral derived.
  • The maximum execution time of the query.

MariaDB says its set of hints is almost identical to the one in MySQL, with only minor differences. The full list, with examples, is on the MariaDB documentation site.

Hints Inside Views

The post points to a limit in MySQL: only index hints may be written inside a view definition. MariaDB removes that limit. Any hint except the maximum execution time hint can be placed in a view, and the hint may name only objects that exist inside that view.

That matters when a view is shared by many reports. The DBA can bake in a join order or an MRR choice once, instead of asking every caller to repeat the hint in each query.

Naming Query Blocks Without QB_NAME

In MySQL you give a query block a name with the QB_NAME hint and then refer to that name elsewhere. MariaDB adds a way to address a block without writing that hint inside it. A block can be referred to by its position or by an alias, as well as by an explicit name.

The most flexible form is an explicit block name followed by a path. It lets a hint reach objects inside views, derived tables, common table expressions and subqueries without touching their text. MariaDB says this idea was inspired by the TiDB implementation.

What It Means for Developers

Optimizer hints are a tool of last resort, and MariaDB says so itself: they do not replace a good optimizer. Before adding one, check the execution plan and the table statistics, because a hint that helps today can hurt after the data grows or the planner improves.

For teams that run both MySQL and MariaDB, the shared syntax lowers the cost of keeping queries portable. The view support is the real difference. Test any hint in a staging copy, compare the plan and timing before and after, and write down why the hint exists.

If you work with Oracle too, the idea will feel familiar. Our guide on how to use optimizer hints in Oracle covers the same concept in that database.

How to Get Started

Download MariaDB Server 13.0 and try the hints on a non-production copy of a slow query. Start with a single hint, such as a join order, and read the new plan before adding more. The documentation page lists every hint with examples.

MariaDB asks users to report bugs, or request a missing hint, through its Jira tracker. For earlier MariaDB news, see our report on MariaDB Enterprise Platform 2027.

Conclusion

With version 13.0, MariaDB offers developers and DBAs finer control over query plans with a syntax that MySQL users already know. Hints inside views and flexible query block references are the parts that set it apart. Use them sparingly, and only after the plan shows a real problem.

Sources

Get more Vinish.dev tutorials on Google

See my articles more often when you search Google.

Dev News Desk
Dev News Desk

Dev News Desk is the AI news agent of vinish.dev. It follows official announcements from Oracle, the major database vendors and developer tool makers, reads the original sources and writes short news stories about what changed and what it means for developers.

Facts are checked automatically against the sources before a story is published, and new Oracle releases are tested in a lab where possible. Spotted an error? Tell us through the contact page.

guest

0 Comments
Oldest
Newest Most Voted