Measure MySQL Query

Mudaser Ali
Sep 3, 2021

If you are interested to measure exact time your query is taking this article is for you

if you have to enable profile in mysql

SET profiling = 1;

Now execute any query i.e.,

SELECT TABLE_NAME, UPDATE_TIME
FROM information_schema.tables
WHERE TABLE_SCHEMA = ‘abc’
ORDER BY UPDATE_TIME DESC;

Now run

SHOW PROFILES;

Now mysql will show you something like this

show profiles; result

You can get more details about any query using its Query_id

SHOW PROFILE FOR QUERY 1;

details result of query profile

You can stop query profiling using following command

SET profiling = 0;

--

--

Mudaser Ali

{ name: Mudaser Ali aka SMAK, skills: NoBody is pErfect i M nObOdy, passion: {love: [programming, photography]} }