如果我的 Redshift/Postgresql 中有一个名为:conn_log 的简单表
从性能来看,这两个命令有什么区别?
select t1.wifi_name, (t2.sconn*100)::numeric/t1.ttconn
from (select wifi_name, count(*) as ttconn
from conn_log
group by wifi_name) t1,
(select wifi_name, count(*) as sconn
from conn_log
where success = 1
group by wifi_name) t2
where t1.wifi_name = t2.wifi_name;
第二个查询:
select t1.wifi_name, (t2.sconn*100)::numeric/t1.ttconn
from (select wifi_name, count(*) as ttconn
from conn_log
group by wifi_name) t1
join
(select wifi_name, count(*) as sconn
from conn_log
where success = 1
group by wifi_name) t2
on t1.wifi_name = t2.wifi_name