Performance tuning can happen at many levels and one among them is tuning in database level. We need to know what are the queries are executing in database. This can be done in application level  by logging the query but this is inbuilt feature in database. We just need to enable it and it will log all the queries fired by the application. We have table called general_log table where queries are stored. We need to enable as like below and by default it will not be enabled.

set global general_log=1;

Logging is enabled, Now we need to mentioned the destination where logging has to go.. We can redirect into file or table. We can set the destination using below query.

set global log_output='TABLE' ;

We are done now. All the queries executing in MYSQL will be captured and logged in a table. We query general_log_table to see the list of queries executing.

select * from mysql.general_log