Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 July MySQL: Using SQL Query Profiler finds total execution time and CPU information of the Queries

MySQL: Using SQL Query Profiler finds total execution time and CPU information of the Queries

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

Microsoft SQL Server Profiler is one of the important tool which is useful to find different events and statues of the running queries on Microsoft SQL Server.

Do we have anything like SQL Profiler in MySQL?

I have found this question on many forums and many of MySQL professionals are curious about SQL Profiler in MySQL.

MySQL has SQL Profiler which is built into the database server and you can enable/disable via the MySQL client utility.

Before executing any queries you can enable SQL Profiler and it is only for your particular session.
Internally, it creates one profiling table into INFORMATION_SCHEMA database and when you disconnect with MySQL client, it destroys this table.

Enable SQL Profile at session level:

1
SET profiling=1;

Execute sample query:

1
2
SELECT *FROM table_one;
SELECT *FROM table_two;

Check the execution time for each query:

1
2
3
4
5
6
7
SHOW PROFILES;
 
/*Result*/
Query_ID Duration Query
--------------------------------------------------
1 0.00355325 SELECT *FROM table_one
2 0.00051850 SELECT *FROM table_two

Check the execution time for second query only:

1
SHOW PROFILE FOR QUERY 2;

Check the CPU information for second query only:

1
SHOW PROFILE CPU FOR QUERY 2;

The Result:

MySQL CPU SQL Profiler

Jul 30, 2016Anvesh Patel
NoSQL: Important System Tables of the CassandraMySQL: How to escape apostrophe and single quote?
Comments: 3
  1. minal
    June 2, 2018 at 5:47 pm

    thanks for sharing multiple scripts, really appreciate your help

  2. Malvir
    July 18, 2018 at 9:47 am

    Great sharing Anvesh, I am using your many of scripts

  3. Keto
    September 27, 2018 at 5:10 pm

    Nice post. I learn something totally new and challenging.
    thank you

Anvesh Patel
Anvesh Patel

Database Engineer

July 30, 2016 MySQL, MySQL DBA ScriptAnvesh Patel, database, database research and development, dbrnd, MySQL, MySQL Command, MySQL Database Administrator, MySQL Database Designing, MySQL Database Programming, MySQL Error, MySQL Performance Tunning, MySQL Query, MySQL Tips and Tricks, profiling, SHOW PROFILES, SQL Profiler
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....