May 22, 2012

Post: Join Optimizations in MySQL 5.6 and MariaDB 5.5

… this optimization actually is. Key-ordered Scan for BKA With this optimization the idea of MRR is further extended to improve join performance. As… col1 would be sorted by col1 i.e. in index order and then the lookup will be performed. So key-ordered scan is basically…_shippriority order by revenue desc, o_orderdate LIMIT 10; In-memory workload Now let’s see how effective are the join optimizations when…

Post: Multi Range Read (MRR) in MySQL 5.6 and MariaDB 5.5

… definition (and hence covering index optimization is not used), then primary key lookups have to be performed for each secondary key entry… key_column, pk_column FROM tbl WHERE key_column=x ORDER BY key_column (Note that secondary keys in InnoDB contain primary… = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc LIMIT…

Post: ORDER BY ... LIMIT Performance Optimization

ORDER BY implementation, especially together with LIMIT is often the cause of MySQL Performance problems. Here is what you need to know about ORDER BY … LIMIT optimization to avoid these problems ORDER BY with LIMIT is…

Post: Using GROUP BY WITH ROLLUP for Reporting Performance Optimization

… “a%” group by grp with rollup order by cnt desc limit 11; ERROR 1221 (HY000): Incorrect usage of CUBE/ROLLUP and ORDER BY Oops. Bad luck – for some reason you can’t use order by together with ROLLUP. This does… well implemented inside MySQL. Why am I looking on reporting performance optimization ? It is for ClickAider project which is growing rapidly and…

Post: Possible optimization for sort_merge and UNION ORDER BY LIMIT

Every so often you need to perform sort results retrieved from MySQL when your WHERE clause goes … index for the order by. Ranges as well as IN lists make this optimization impossible, not even speaking about index merge optimization. Lets look… get resulted rows in sorted order. Once this is implemented similar approach could be used for optimizing ORDER BY with IN. This original query…

Post: Is it query which needs to be optimized ?

… are couple of examples: GROUP BY Consider SELECT COUNT(*) cnt, page FROM log GROUP BY page ORDER BY cnt DESC limit 10, the query… as possible. ORDER BY I already wrote about ORDER BY LIMIT Optimization so I will not repeat it here. In the nutshell ORDER BY LIMIT can be… make sure for queries you’re going to run ORDER BY .. LIMIT can be performed using the index, for example simple JOIN is…

Post: MySQL Performance - eliminating ORDER BY function

… rules you would learn about MySQL Performance Optimization is to avoid using functions when comparing constants or order by. Ie use indexed_col=N… you look only at ORDER BY clause you would see first query which sorts by function is able to avoid order by while second which… this case MySQL Optimizer is rather smart and is able to do this even if we have function in ORDER BY and exactly…

Post: Goal driven performance optimization

performance optimization potential. But let us get back to the Server Side Optimization. Lets assume our performanceoptimize something, my checklist is usually get rid of it, cache it, tune it, get more hardware in this order…and it becomes 90% or so driven by Sphinx. This tells us there is some…

Post: Using index for ORDER BY vs restricting number of rows.

… with MySQL Optimizer I frequently run into is making poor decision when it comes to choosing between using index for ORDER BY or… there are also bunch of fields which sorting can be performed on such as seller, price, date added etc. Such configuration… * from goods where cat_id=5 and seller_id=1 order by price desc limit 10 \G *************************** 1. row *************************** id: 1 select…

Post: Extending Index for Innodb tables can hurt performance in a surprising way

… * from idxitest where a=100 order by id desc limit 1; +—-+————-+———-+——+—————+——+———+——-+——+——————————————+ | id | select_type …ordering of data by primary key inside indexes they can become significantly affected. Optimizer