I have a query which gets different query plans over time and one of them takes less then a minute to execute, the other one takes days. Can I tell the db to use a given plan (taken from explain or using inline instructions) so that the good plan is always used or at least the catastrophical one gets always avoided? The good plan has only ref joins while the bad one also has index and eq_ref and a different ordering.
There are al lot of passibilities to force mariadb
- Forcing Join Order
- Forcing Usage of a Specific Index for the WHERE Clause
- USE INDEX: Use a Limited Set of Indexes
- IGNORE INDEX: Don't Use a Particular Index
- FORCE INDEX: Forcing an Index
how they work and how to use it