Run ANALYZE TABLE — Do Not Rely on InnoDB's Automatic Recalculation of Statistics
Øystein on MySQL Optimizer
by
2y ago
This blog post is inspired by Jesper's recent blog post on how the automatic update of InnoDB persistent statistics may never trigger if servers are restarted frequently. However, the matter is even worse! In this blog post I will show that even when the automatic recalculation is performed, there are no guarantees as to when the server will see the changes. Myths about persistent statistics I must admit that I, for a long time, believed in the myths I was told about when updates to InnoDB's index statistics become visible to the query optimizer. There were basically two variants: The updated ..read more
Visit website
Use Window Functions to Speed Up Correlated Subqueries
Øystein on MySQL Optimizer
by
3y ago
In my previous blog post, I discussed different ways to rewrite correlated scalar subqueries to improve performance. In this blog post, I will discuss how we can use window functions for a subset of these queries. Window functions was introduced in MySQL 8.0. Use case Often we run queries to find rows within a table with values that are, e.g., smaller, greater, or equal to some metric computed over a set of rows from the same table. Some examples are: Find orders for more than 1% of the total revenue for the last week. Find the supplier with the lowest price for a certain part. Find orders fo ..read more
Visit website
Transformations of Correlated Scalar Subqueries
Øystein on MySQL Optimizer
by
3y ago
MySQL 8.0.24 introduces transformation of correlated scalar subqueries to derived tables. In my presentation in the MySQL devroom at FOSDEM earlier this year, I showed how we can manually rewrite such queries. The automatic transformation in MySQL 8.0.24 is off by default, and in this blog post, I will discuss when it makes sense to turn it on. We will also look at how this automatic transformation compares to manual rewritten queries. Example query I will use the same query as in my FOSDEM presentation: SELECT SUM(l_extendedprice) / 7.0 AS avg_yearly FROM lineitem JOIN part ON p_partkey = l_ ..read more
Visit website
Memory Usage for MySQL Hash Join
Øystein on MySQL Optimizer
by
4y ago
At Percona Live Online my colleague at Alibaba, Jim Tommaney, presented a study of hash join performance in MySQL and Marwho?iaDB. For some of the queries, the peformance characteristics for MySQL seemed a bit strange, and I decided to look closer into what was going on. As you can read below, I found that the crucial point was the memory usage of hash join in MySQL. Results presented at Percona Live ONLINEIn Jims presentation, you can see the following graphs for the performance of his query 2.2 on MySQL and Marwho?iaDB: We see that for Marwho?iaDB, the performance scales pretty linear wi ..read more
Visit website
MySQL Parallel Index Range Scans: One is Sometimes Better Than Two
Øystein on MySQL Optimizer
by
4y ago
As presented at the Percona Live Conference in Austin in May, at Alibaba we are working on adding support for parallel query execution to POLARDB for MySQL. As discussed in the presentation, we observe that parallel range scans on secondary indexes does not scale very well in MySQL. This is old news. Mark Callaghan reported this several years ago, and this does not seem to have changed. In this blog post, I will investigate what effects using a multi-processor machine have on the scalability of parallel index range scans. I will run a variant of Query 6 of the TPC-H/DBT-3 benchmark. While th ..read more
Visit website
Inspecting the Content of a MySQL Histogram
Øystein on MySQL Optimizer
by
4y ago
FOSDEM is coming up. I do not have a presentation in the MySQL and Friends devroom this year, but it reminded me that I had planned to post a follow-up to my presentation from last year. As part of the presentation, I showed how you can inspect the content of a histogram using the information schema table column_statistics. For example, the following query will show the content of the histogram for the column l_linenumber in the table lineitem of the dbt3_sf1 database: SELECT JSON_PRETTY(histogram) FROM information_schema.column_statistics WHERE schema_name = 'dbt3_sf1' AND table_name ='lin ..read more
Visit website
My presentations at Percona Live
Øystein on MySQL Optimizer
by
5y ago
Percona Live 2019 is starting in Austin today.  You may already have read that I have a presentation on how to use Optimizer Trace to understand the inner workings of the MySQL Query Optimizer: The MySQL Query Optimizer Explained Through Optimizer Trace on Wednesday at 2:55pm. I hope to see many of you there! Together with my colleague Benny Wang, I will also be presenting the current work we do at Alibaba to add parallel query processing to PolarDB for MySQL.  If you want to learn more about our work, come to the presentation on Thursday at 11:00am. Many other of my colleagues at Alibaba ha ..read more
Visit website

Follow Øystein on MySQL Optimizer on FeedSpot

Continue with Google
Continue with Apple
OR