0
0
MySQLquery~20 mins

Monitoring and profiling in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
MySQL Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Identify slow queries using MySQL slow query log
You enabled the slow query log in MySQL with the following settings:

slow_query_log = ON
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2


What will be the output of the command below?

tail -n 5 /var/log/mysql/mysql-slow.log
AShows the first 5 queries executed since MySQL started
BShows the last 5 queries regardless of execution time
CShows an error because the slow query log file path is incorrect
DShows the last 5 slow queries that took longer than 2 seconds to execute
Attempts:
2 left
💡 Hint
The slow query log records queries that exceed the long_query_time threshold.
Configuration
intermediate
1:30remaining
Configure MySQL to enable performance schema for profiling
Which configuration snippet correctly enables the Performance Schema in MySQL for detailed query profiling?
A
[mysqld]
performance_schema=TRUE
B
[mysqld]
performance_schema=ON
C
[mysqld]
performance_schema=1
D
[mysqld]
enable_performance_schema=ON
Attempts:
2 left
💡 Hint
Check the exact variable name and accepted values in MySQL documentation.
Troubleshoot
advanced
2:00remaining
Diagnose why slow query log is not recording queries
You enabled the slow query log with:

SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 1;


But no queries appear in the slow query log file. What is the most likely cause?
AThe MySQL user does not have write permission to the slow query log file location
BThe long_query_time is set too low to capture any queries
CThe slow query log requires a server restart to take effect
DThe slow query log file path is not set, so logging is disabled
Attempts:
2 left
💡 Hint
Check file permissions and ownership for the log file path.
🔀 Workflow
advanced
2:30remaining
Steps to profile a query using Performance Schema
Arrange the steps in the correct order to profile a slow query using MySQL Performance Schema.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Profiling requires enabling, running, then analyzing.
Best Practice
expert
3:00remaining
Best practice for continuous MySQL query performance monitoring
Which approach is best for continuous monitoring of MySQL query performance in a production environment?
AEnable slow query log with a low long_query_time and manually analyze logs daily
BDisable all logging to maximize performance and only enable logs during incidents
CUse Performance Schema with automated tools to collect and visualize query metrics continuously
DRun EXPLAIN on all queries manually every week to check performance
Attempts:
2 left
💡 Hint
Consider automation and minimal manual effort for continuous monitoring.