Can I tell mariadb which query plan to use for a given query? 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 

for example: 


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

https://mariadb.com/kb/en/index-hints-how-to-force-query-plans/