Summary: An alternate approach, offered in response to our
original post, provides excellent improvements
for smaller databases, but clustered indexes offer better
performance as database size increases. (This posting is by
Dave.)
Jay Pipes suggested an alternate approach to improving MySQL
performance of Query 17 on a TPC-H-like database.
-
- Add the index (l_partkey, l_quantity) to the lineitem
table.
- Re-write the query as:
select sum(li.l_extendedprice) / 7.0 as avg_yearly from lineitem li inner join part p on li.l_partkey = p.p_partkey inner join ( select l_partkey, 0.2 * avg(l_quantity) as quantity from lineitem group by l_partkey ) as quantities on …