Mysql – Can creating indexes colide with future database upgrades

indexMySQL

I have a mysql Database with very slow querys. I am using the slow query log to monitor those.

This is a database created by a third party software that we're using. Their developers didn't do any kind of optimization at this level on the database. Some indexes would certainly improve performance.

My main concern is that my indexes may collide with future database upgrades (structural or index creation).

By nature indexes are not invasive in the DB structure/data, but upon table change they may? prevent these from happening successfully.

Can I add indexes safely, with the certainty that they will be handled (maybe even dropped) if changes need to be done, or should I avoid that?

Best Answer

What I would do is maintain a SQL script for the indexes that you've added to the "virgin" database. Store this script in a version control system, as you'll be adding indexes to fix performance problems.

I would employ a naming strategy to make it easy to identify which indexes are "yours" and not part of the database as delivered. I'm not sure what features MySQL has, but in Oracle for example you can store these indexes in a different tablespace making it very easy to identify them as "added".

When your vendor supplies an upgrade, first remove your added indexes, then apply your vendor's upgrade and afterwards execute your script to add your indexes.

Of course, you should also have a QA environment where you can test all of this before applying it to your production system. You'll need to do this to discover if any indexes will conflict with indexes that the vendor may create in a future version.