+ -
当前位置:首页 → 问答吧 → 以下两段sql有性能区别吗?

以下两段sql有性能区别吗?

时间:2011-12-12

来源:互联网

以下两段sql有性能区别吗?
1、嵌套子查询
select asn.bl_no,max(file.id) as bl_file_id
from (select asnpo.bl_no
from cp_order_asn_po asnpo
where asnpo.bl_file_id is null and asnpo.bl_no is not null and asnpo.bl_no <> '') as asn,

(select id,filename from cp_flow_fileupload 
where cp_flow_fileupload.modeltype=8
and cp_flow_fileupload.pageflag=13
and cp_flow_fileupload.filetype=1 ) as file
where file.filename like '%'|| asn.bl_no ||'%'
group by asn.bl_no


2、全联结查询
select asnpo.bl_no,max(file.id) as bl_file_id
from cp_order_asn_po asnpo,cp_flow_fileupload file
where file.filename like '%'|| asnpo.bl_no ||'%'
and asnpo.bl_file_id is null and asnpo.bl_no is not null and asnpo.bl_no <> ''
and file.modeltype=8
and file.pageflag=13
and file.filetype=1
group by asnpo.bl_no

sql中cp_order_asn_po和cp_flow_fileupload都有几万条数据,以后还会更多,用哪个sql更好点?

作者: chishan911   发布时间: 2011-12-12

where file.filename like '%'|| asn.bl_no ||'%'这个是什么意思

两个表没有连接条件吗 自然连接 笛卡尔积?

作者: rucypli   发布时间: 2011-12-12