Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mySQL Indexes suggestion software

Is there any software that can analyze a mySQL query, and suggest a specific index creation.

I know its best to do it by hand, but i need to something that can save some time.

Many thanks,

like image 352
Benjamin Ortuzar Avatar asked Oct 06 '11 22:10

Benjamin Ortuzar


2 Answers

The MySQL Enterprise Monitor has a Query Analyer feature. But MEM is not free.

Percona Toolkit is a free, open-source software product that gives you most of the information to do the analysis yourself.

  • pt-query-digest --explain analyzes the top queries that appear in your query log and shows you their current optimization plan.

  • pt-index-usage analyzes the queries in your query log and shows you how they are using indexes (and also shows you indexes that it considered but decided not to use).

Full disclosure: I work for Percona.

like image 120
Bill Karwin Avatar answered Nov 08 '22 06:11

Bill Karwin


Well, this won't automate the process, but it explains how you can figure out what the best INDEX is for a given SELECT: Index Cookbook

I agree with Bill that pt-query-digest (together with the slowlog) is an excellent way to identify the "worst" queries. (Disclosure: I do not work for Percona.)

like image 40
Rick James Avatar answered Nov 08 '22 07:11

Rick James