MySQL Forums
Forum List  »  Performance

Re: reduce execution time of query
Posted by: Rick James
Date: January 29, 2014 03:44PM

Please use explicit JOIN (instead of "comma join").

Please use short aliases; long ones clutter the query and make it hard to read.

select  sum(rf.total_price) as m0
    from  category_groups as cg
    join  dim_products as dp on dp.product_category_group_sk = cg.product_category_group_sk
    join  revenue_facts as rf on rf.product_sk = dp.product.sk
    group by  cg.category_name ;

Check the result -- sometimes users are in for a surprise when using GROUP BY with JOIN; the sum may be many times as big as expected.

> I already have indexes on ... the columns in join.

Please provide SHOW CREATE TABLE for each table, so we can check engines, datatypes, etc.

Options: ReplyQuote


Subject
Views
Written By
Posted
5285
January 29, 2014 03:50AM
1488
January 29, 2014 11:59AM
Re: reduce execution time of query
1544
January 29, 2014 03:44PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.