Re: query performance optimization
Hi,
I am not able to understand what your query is supposed to do. The GROUP BY clause puzzles me:
GROUP BY SFO.entity_id AND SOIT.id_tags IN (2,3,8,10,11,12)
Grouping on a logical expression means you will get two groups, one for the rows where the expression is TRUE and one for rows where the expression is FALSE (and maybe an additional NULL group if SOIT.id_tags happens to be NULL for some rows.) This does not make much sense since you will just get data from some arbitrary row within each group. In this context, LIMIT 5 does not make much sense either since there will never be more than 3 rows in the result.
Which version of MySQL are you using?
Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway