I have most of the queries like
select distinct A.id from tab_a A
left join tab_b B on A.col_1=B.col_2
left join tab_c C on B.col_3=C.col_4
where B.col_2=‘xyz’ and C.col_3=‘111’
group by A.name, A.id
these are dynamic queries generated in java; WHERE clause is decided based on user’s inputs
mentioned only 3 tables but there are 10.
Now my questions are
Does GROUP BY has performance issues ?
Why doesn’t MySQL check queries if GROUP BY is used but not any aggregate function ? Oracle, SQL server will throw exceptions in such queries.
Isn’t EXISTS will be better than JOIN in this scenario as we need to filter out id (which is pk) from parent table (tab_a) based on records matching certain params in child table(s)