“具有查询”与“临时表”的性能比较

时间:2019-03-21 00:50:13

标签: sql amazon-redshift

明智地选择查询性能> 1)进行查询或2)临时表中的哪个更好

1)

 with table_map as ( select * from t1 where x=y),
    select col1, sum(col) from table_map group by 1
    union all
    select col2, sum(col) from table_map group by 1
    union all
    select col3, sum(col) from table_map group by 1

2)

 create temp table tmp_details as (select * from t1 where x=y) 
select col1, sum(col) from tmp_details group by 1
union all
select col2, sum(col) from tmp_details group by 1
union all
select col3, sum(col) from tmp_details group by 1

0 个答案:

没有答案