Embed presentation
Download as PDF, PPTX









![cursor = conn.cursor()q = ’’’UPDATE ‘foo‘ SET my_date=NOW(),subject = %s,msg = %s,address = %s,updated_at = NOW()WHERE id=%s’’’cursor.execute(q, [remote_resp.get(’subject’),remote_resp.get(’msg’),remote_resp.get(’address’),my_id])Slow Query6](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-10-2048.jpg&f=jpg&w=240)
![cursor = conn.cursor()q = ’’’UPDATE ‘foo‘ SET my_date=NOW(),subject = %s,msg = %s,address = %s,updated_at = NOW()WHERE id=%s’’’cursor.execute(q, [remote_resp.get(’subject’),remote_resp.get(’msg’),remote_resp.get(’address’),my_id])Slow Query6](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-11-2048.jpg&f=jpg&w=240)













































![• More information than in regular EXPLAIN•Cost statistics• Which part of index chosenmysql> explain format=json SELECT first_name, last_name FROM employee-> WHERE first_name=’Steve’ and last_name like ’V%’-> and hire_date > ’1990-01-01’G*************************** 1. row ***************************EXPLAIN: {..."used_key_parts": ["first_name","last_name"],EXPLAIN FORMAT = JSON40](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-57-2048.jpg&f=jpg&w=240)
![• More information than in regular EXPLAIN•Cost statistics• Which part of index chosen• Columns, used to resolve querymysql> explain format=json select count(*) from Country-> where Continent=’Africa’ and Population > 1000000G*************************** 1. row ***************************..."used_columns": ["Continent","Population"],EXPLAIN FORMAT = JSON40](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-58-2048.jpg&f=jpg&w=240)










![•SHOW [FULL] PROCESSLIST•INFORMATION SCHEMA.PROCESSLIST•performance schema.THREADSPROCESSLIST47](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-69-2048.jpg&f=jpg&w=240)
![•SHOW [FULL] PROCESSLIST•INFORMATION SCHEMA.PROCESSLIST•performance schema.THREADS• Your first alert in case of performance issuePROCESSLIST47](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-70-2048.jpg&f=jpg&w=240)
![•SHOW [FULL] PROCESSLIST•INFORMATION SCHEMA.PROCESSLIST•performance schema.THREADS• Your first alert in case of performance issue• Shows all queries, running at the momentPROCESSLIST47](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-71-2048.jpg&f=jpg&w=240)






























The document provides an introduction to MySQL query tuning, discussing the factors affecting query execution and the mechanics of the MySQL optimizer. It highlights the importance of indexing, explains how to analyze query performance using the EXPLAIN statement, and outlines various scenarios affecting query speed. Additionally, it emphasizes the relative nature of query performance based on data size, use cases, and server configurations.









![cursor = conn.cursor()q = ’’’UPDATE ‘foo‘ SET my_date=NOW(),subject = %s,msg = %s,address = %s,updated_at = NOW()WHERE id=%s’’’cursor.execute(q, [remote_resp.get(’subject’),remote_resp.get(’msg’),remote_resp.get(’address’),my_id])Slow Query6](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-10-2048.jpg&f=jpg&w=240)
![cursor = conn.cursor()q = ’’’UPDATE ‘foo‘ SET my_date=NOW(),subject = %s,msg = %s,address = %s,updated_at = NOW()WHERE id=%s’’’cursor.execute(q, [remote_resp.get(’subject’),remote_resp.get(’msg’),remote_resp.get(’address’),my_id])Slow Query6](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-11-2048.jpg&f=jpg&w=240)













































![• More information than in regular EXPLAIN•Cost statistics• Which part of index chosenmysql> explain format=json SELECT first_name, last_name FROM employee-> WHERE first_name=’Steve’ and last_name like ’V%’-> and hire_date > ’1990-01-01’G*************************** 1. row ***************************EXPLAIN: {..."used_key_parts": ["first_name","last_name"],EXPLAIN FORMAT = JSON40](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-57-2048.jpg&f=jpg&w=240)
![• More information than in regular EXPLAIN•Cost statistics• Which part of index chosen• Columns, used to resolve querymysql> explain format=json select count(*) from Country-> where Continent=’Africa’ and Population > 1000000G*************************** 1. row ***************************..."used_columns": ["Continent","Population"],EXPLAIN FORMAT = JSON40](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-58-2048.jpg&f=jpg&w=240)










![•SHOW [FULL] PROCESSLIST•INFORMATION SCHEMA.PROCESSLIST•performance schema.THREADSPROCESSLIST47](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-69-2048.jpg&f=jpg&w=240)
![•SHOW [FULL] PROCESSLIST•INFORMATION SCHEMA.PROCESSLIST•performance schema.THREADS• Your first alert in case of performance issuePROCESSLIST47](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-70-2048.jpg&f=jpg&w=240)
![•SHOW [FULL] PROCESSLIST•INFORMATION SCHEMA.PROCESSLIST•performance schema.THREADS• Your first alert in case of performance issue• Shows all queries, running at the momentPROCESSLIST47](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fqt-2018-180418161042%2f75%2fIntroduction-into-MySQL-Query-Tuning-71-2048.jpg&f=jpg&w=240)




























