与创建临时表一起加入所有内容

时间:2017-05-17 15:27:21

标签: sql-server join temp-tables

我有两个问题:

1)

SELECT us.naam, count(DISTINCT DATE(usi.datetime)) as days
FROM users_social as us
JOIN users_social_invoer as usi
  ON us.user_id = usi.user_id
WHERE us.user_id = 1    
GROUP BY us.naam

2)

select a.*
      ,b.*
      ,c.*
into final_table
from table_a as a
    left join table_b as b
        on a.id_1 = b.id_1
    left join table_c as c
        on a.id_2 = c.id_2;

我观察到第二个查询在SQL Server 2012上的运行速度明显更快。是偶然的,还是有充分的理由呢?

0 个答案:

没有答案