SQL Join Table vs. Select -
i have inherited legacy sql code following snippet (i've anonymized simplicity sake).
create external table dim_abc (user_id int) create table dim_foo select user_id, ... my_table join (select * dim_abc) b on (a.user_id = b.user_id)
instead of...
from my_table join dim_abc b on (a.user_id = b.user_id)
any idea why previous developer have done select within join?
** code hive.
the version without subselect better variety of reasons. databases (you don't mention database) lose ability use indexes on dim_abc
because of subquery.
that not question, though. best guess code started out more complicated. dim_abc
might have required logic @ 1 point in time. code simplified, end result useless subquery in from
clause. guess, offers 1 plausible scenario.
Comments
Post a Comment