mysql - SQL Query - Count Group By Very Slow - Help Optimise -
Please see my mysql query below, which I want to optimize. I'm sure there is a more efficient way to do this, but I'm not just working for my life. Can anyone help please? I think there should be a way of stopping multiple combinations.
select network_name, phones_count as deals_tempd inner join phone p on d.model_id = p as count_count (*). Model_id Tariff tax tax at INNER d.tariff_id = t.tariff_id INNER network en ON d.network_id = n.network_id Join INNER free_gift fg ON d.freegift_id = fg.freegift_id INNER merchants meet d.merchant_id = m .merchant_id INNER JOIN type ty ty tytyty_id = d.type_id WHERE network_name! = '' Group Select network_name Unon all Tariff_contentlength, Count_temp Count as a phone call from D (*) dn.model_id = p.model_id Phone PO Inner Access Tariff Tax ON d.tariff_id = t.tariff_id INNER includes the network Get d.network_id = n.network_id INNER Join free_gift fg ON d.freegift_id = fg.freegift_id INNER merchants meet d.merchant_id = m.merchant_id INNER JOIN type ty ty ty .type_id = d.type_id where tariff_computer lamp! = 1 Group Tariff_contentlength Unius Select all offer_freegif T, count (*) as phone_mount to deals_temp D Inner Jones Phone P On D. Modded Adid = P.MODL_ID Inner Tariff Tax On D.tirf_id = T.T.R. .fi_idInner Join NetworkNon onDNetwork_ID = NNetwork_IDInnerFreeGift Fg ONd.freegift_id = fg.freegift_id INNER merchants meet d.merchant_id = m.merchant_id INNER JOIN type ty tytyty_id = d.type_id WHERE offer_freegift! = '' Offer_figft by group OK I'll explain something else just this. I thought it could be very quick.
Then I have the following applause
deals_temp model_id | Tariff_id |
123 | 1234
123 | 1235
123 | 1236
124 | 1237
Phone model_id | Model_make | Model_basename
123 | Apple | IPhone
124 | Apple | iPad
Tariff tariff_id | Tariff_name
1234 | Unlimited 30
I need to calculate the number of rows (lines) based on specific values in the other tables in deals_temp eg. Phone (model_make) and tariff (tariff_name)
should be output:
element | Count
iPhone | 123
iPad | 543
Apple | 453
unlimited 30 | 564
The first step will be to ensure that all your IDs are indexed on the field Inserting from inside
The second step will be to ensure that you have the indexes in the variable, where you are referring in your reference, (network_name, tariff_contact lamp, offer_freegift)
In addition to this, when you remove unions, you have some very straightforward Scope of the question, which means that they do not look very complicated.
Not sure if MySQL is the Query Optimizer, you can review it but there will be a place to start it. My guess is to look at your inquiries that most of your data is included Time is being spent, which means either you should not include that much data, or start gobbling up your server stats or building cube ... (I do not recommend the last two Ga]
Comments
Post a Comment