How to properly debug and inspect SQL Queries in PHP File?
SET GLOBAL long_query_time = 1;
to log slow queries taking 1 second or more.

EXPLAIN EXTENDED SELECT ..... to see valuable information about how the query is getting to the result.

Follow immediately in the same session,
SHOW WARNINGS;
to see how the Optimizer rearranged the sequence of events.
(Rick James, thanks for the reminder.)