Here is a tip you can use when writing a stored procedure, and using prepared statements. Since you have to pass the statements in through EXECUTE stmt USING … it can get confusing if there are a large number of
SQL EXPLAIN: The “Extra” column
This column contains additional information about how MySql resolved the query. There is a line in the manual which states: If you want to make your queries as fast as possible, look out for Extra values of Using filesort and Using temporary. Let’s examine why