Sometimes, the MySQL Optimizer chooses a wrong plan, and a query that should execute in less than 0.1 second ends-up running for 12 minutes ! This is not a new problem: bugs about this can be traced back to 2014, and a blog post on the subject dates of 2015. But even if this is old news, because this problem recently came to my attention, it is a problem worth writing on.
Showing posts with label Optimizer. Show all posts
Showing posts with label Optimizer. Show all posts
Tuesday, November 15, 2022
Bad Optimizer Plan on Queries Combining WHERE, ORDER BY and LIMIT
Labels:
Bugs,
MySQL,
optimization,
Optimizer,
Query plan,
War Story
Tuesday, March 8, 2022
Rows Examined not Trustworthy because of Index Condition Pushdown
When Index Condition Pushdown is used, you cannot trust rows examined as reported by the slow query log (nor in some Performance Schema tables) and you cannot trust the global status Innodb_rows_read (nor the InnoDB Metrics dml_reads). These can lead to an incorrect query complexity analysis, to a mistaken estimation of the total load of a MySQL server, and to a lot of wasted time. As we go through the details in this post, we will understand why a SELECT * is sometimes faster than only selecting the columns from an index (we would normally expect the opposite) and we will visit inner workings of the MySQL Storage Engine Architecture. But first, let's start by exposing the problem.
Labels:
Blindspot,
Index Condition Pushdown,
MySQL,
Optimizer,
Performance Schema,
rows examined,
Storage Engine
Subscribe to:
Posts (Atom)