MySQL – Execution Plan Recompile

execution-planMySQL

I've added a new index to account for some performance issues however the queries that I would expect to be using the new index are still are not using it. In SQL Server you can flush an execution plan a couple of different ways to correct a poor performing query and I'm looking to understand if that is also possible in MySQL.

  • Can a specific execution plan be removed?
  • Can a all of the stored execution plans be removed?

Best Answer

Sadly, you cannot do that with MySQL.

Notwithstanding, there are two things try

1: Tweek the Query Optimizer

You can change the Query Optimizer behavior. Please see my posts about doing so, but always check the MySQL Documentation first and foremost.

2: Make MySQL use the index

Rather that reinvent the wheel, see my old post from Oct 28, 2011, Using FORCE INDEX