Skip to content

Common-schema: redundant keys on MySQL-MariaDB

common schema

Let’s keep on learning more and more about common-schema, and I execute a query about redundant keys:

SELECT * FROM common_schema.redundant_keys;

The result to this query informs me that these keys are, literally, redundant, and the optimal solution si to remove them. Also, the query has more interesting information!

After this, you think: “Well, if they are redundant, let’s remove it“. But, included in the previous query, there is a filed called “sql_drop_index” with the SQL sentence to remove the index.

Even more, because common_schema includes a function EVAL very useful to execute all this prepared SQL sentence, all in one SQL sentence:

call eval("SELECT sql_drop_index FROM common_schema.redundant_keys")

If you only want to try on one database, lust add a WHERE clause to the previous SQL sentence, like this:

call eval("
SELECT sql_drop_index FROM common_schema.redundant_keys 
WHERE table_schema='my_database'

And .. that’s all for today. I hope you have fun and … keep on shape your databases!

Have a nice day!

Manejando Datos Newsletter

Noticias, entradas, eventos, cursos, … News, entrances, events, courses, …

Gracias por unirte a la newsletter. Thanks for joining the newsletter.