mysql - Inner Joins over Multiple Tables -
i think, have misconception, how join works on multiple tables. lets have 3 tables a, b, c , need join them.
here v1
select a.name name1 ,b.name name2 ,c.name name3 inner join b on a.id = b.id inner join c on b.id = c.id
here v2
select a.name name1 ,d.name name2 ,d.name name3 inner join ( select b.name name2 ,c.name name3 b inner join c on b.id = c.id ) d on a.id = d.id
is there performance difference between 2 versions? though first query looks cleaner, need build query builder ui, restricting joins 2 tables helps.
in general, problem subselects can require rdbms create temporary table fulfill subselect - , on large enough table can serious expense - , potentially can't use indexes on subselect optimize query, , you're scanning table.
of course, ddl , size of tables aren't included, best way have postgres explain plans , compare/contrast.
Comments
Post a Comment