明智地选择查询性能> 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