MySQL hint/trick: procedure analyse

My good friend Ian (isnoop.net), a great guy and amazing developer, pointed out this MySQL function: PROCEDURE ANALYSE. To quote the website (2nd paragraph):

ANALYSE() examines the result from a query and returns an analysis of the results that suggests optimal data types for each column that may help reduce table sizes. To obtain this analysis, append PROCEDURE ANALYSE to the end of a SELECT statement.

Simple, helpful analysis. It doesn’t ‘fix’ things but is a nice, additional tool to EXPLAIN. What’s most unique, though, is that this function is buried in the “Extending MySQL :: Adding New Procedures to MySQL” section.  I would never go to these pages in MySQL.com as I can’t think of anything I need MySQL to do that it doesn’t do already… I’m no DBA to be sure!

But I DO have a pretty bizarre SELECT I need to write today. I’m looking forward to seeing how EXPLAIN and PROCEDURE ANALYSE might help me in not burying our MySQL server!

UPDATE:
This is all going away… per the webpage on MySQL.com:

PROCEDURE ANALYSE() is deprecated as of MySQL 5.7.18, and is removed in MySQL 8.0

I have a suspicion this is just being replaced with something else…

Leave a comment