Suggestions
The optimizer looks at your queries, tables and indexes, and proposes changes that make lookups faster. You apply them, and undo them, with one click.
How it works
Press Analyze now under Problems → Suggestions. It looks at the queries seen since the server started and the most expensive query patterns of the last 7 days from the history, so it has something to say right after a restart too.
After an analysis, What was checked shows the four things it looked at (missing indexes, duplicate indexes, old MyISAM tables and fragmented tables) and how many suggestions each one gave.
What it can fix
| suggestion | when it is made |
|---|---|
| Missing index | queries filter a table of 200 rows or more on a column that no index starts with. For queries seen since the start, the MariaDB execution plan must confirm that the whole table is read |
| Two-column index | queries filter a table of 5000 rows or more on two columns together and no index covers both. Not suggested when an existing index already narrows the query down to a few hundred rows. The column with more distinct values goes first |
| Index for sorting | a query takes the first rows in a sorted order (ORDER BY ... LIMIT) from a table of 5000 rows or more, and the execution plan shows that MariaDB sorts all matching rows each time |
| For later | a column scripts look rows up by (citizenid, identifier, owner, license, plate...) has no index on a table that is still small. Costs nothing today, slows down as the table grows. Shown with low priority, at most 15 |
| Redundant index | an index that another index already covers |
| MyISAM table | convert to InnoDB |
| Fragmented table | OPTIMIZE TABLE |
It is kept deliberately careful:
- nothing is suggested for a table that already has 10 indexes, since every index slows writes down
- a narrower suggestion is dropped when a wider one already starts with the same column
- long text columns are indexed by their first characters, and columns that cannot be indexed are skipped
- nothing is ever applied by itself
Only changes that one click can make are suggested. Advice that would have to be carried out by hand, such as rewriting a script's query or editing my.ini, is deliberately not shown.
Applying a change
- The table is backed up first, every time. If the backup fails, nothing is changed. The last 15 of these backups are kept ("before optimization" on the Backups page); older ones are removed.
- Applying asks for confirmation, and every applied change is listed with an Undo button.
- Only fixed, checked statements run. The panel sends only the suggestion's ID; the server rebuilds the SQL itself from a fresh analysis.
