Skip to content

Instantly share code, notes, and snippets.

@theArjun
Last active August 17, 2019 03:53
Show Gist options
  • Select an option

  • Save theArjun/74ec875464e4e87807d609401b1791f7 to your computer and use it in GitHub Desktop.

Select an option

Save theArjun/74ec875464e4e87807d609401b1791f7 to your computer and use it in GitHub Desktop.
Check the Execution Time Period of SQL Queries

Start the profiler with

SET profiling = 1;

Then execute your Query.

With

SHOW PROFILES;

you see a list of queries the profiler has statistics for. And finally you choose which query to examine with

SHOW PROFILE FOR QUERY 1;

or whatever number your query has.

What you get is a list where exactly how much time was spent during the query.

More info in the manual.

-- First, I started the profiler with :
SET
profiling = 1;
-- Then, I executed the query with sub-query.
SELECT
*
FROM
class
WHERE
name IN
(
SELECT
name
FROM
class
WHERE
fid = "f501"
)
;
-- Again, I executed the normal query.
SELECT
*
FROM
class
WHERE
fid = "f501";
-- Finally, I got the stats.
show profiles;

The output of the above query was :

query_executiontime

Hence, it can be concluded that sub query takes more time to execute than the normal SQL query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment