sql - Optimising MySQL count(*) query -
i'm creating mysql query needs count number of rows associated each column. wondering if me optimise it's taking around 10 seconds run , website. (not ideal)
the query is:
select model_make, count(*) deals group model_make union select model_brand, count(*) deals group model_brand union select model_name, count(*) deals group model_name;
i'm sure there quicker way this? if way run this, other options there speed up?
ensure have index on each of columns grouping on. still, mysql must scan through index.
other solution calculate counts once , store them update them needed.
Comments
Post a Comment