mySQL query optimisation - multple group by's and UNION ALL -
i'm having trouble query of mine website enables users search mobile phones. idea when user selects filter - i.e. 'iphone', relevant search critera show.
you can view functionality here http://www.comparephonemarket.co.uk/search.php
the table holds of deals called 'options' , looks this:
model_make model_name model_basename model_colour apple iphone iphone 5s blue apple iphone iphone 5s black apple iphone iphone 5s green
this table of phone deals in criteria users can filter by.
currently it's taking around 7 seconds query indexes on of fields little slow. there around 600k rows.
the sql statement produces options looks this:
select model_make `element` options where1 group model_make union select model_basename `element` options 1 group model_basename union select model_colour `element` options 1 group model_basename;
the resulting table looks like
element acer alcatel apple asus iphone 5c blue
then in code clause put onto each of options in sub queries returns relevant results filtering.
does know more optimal way of doing query or quicker way of doing entirely?
Comments
Post a Comment