优化查询语句
select * from t_resource_cell where res_id in ( select c.res_id from t_resource_cell c inner join t_resource_type t on c.res_id = t.res_id where c.status != 'D' and c.mtype_id in (select mtype_id from d_resource_mtype where parent_id in ('RT') or mtype_id in ('RT') ) and ( (c.tmcp_id is not null and c.tmcp_id in ('BQ0007')) or (c.tmcp_id is null and c.res_id in ( select res_id from t_resource_tmcp where tmcp_id in ('BQ0007') ) ) ) and t.type1_id = '2100' and t.type2_id = '8100' )
请帮忙看看怎么能将这个查询优化一下!
问题点数:100、回复次数:3Top
1 楼zlz_212(ShREk)回复于 2006-03-15 13:13:09 得分 10
in 操作看看是否可以替换成其他的,比如existsTop
2 楼bobfang(匆匆过客)回复于 2006-03-15 13:56:34 得分 80
select * from t_resource_cell c
where c.status != 'D'
and c.mtype_id in (select mtype_id from d_resource_mtype where parent_id in ('RT') or mtype_id in ('RT') )
and ( (c.tmcp_id is not null and c.tmcp_id in ('BQ0007') )
or (c.tmcp_id is null and c.res_id in ( select res_id from t_resource_tmcp where tmcp_id in ('BQ0007') ) ) )
and exists (select 1 from t_resource_type t
where c.res_id = t.res_id
and t.type1_id = '2100' and t.type2_id = '8100')Top
3 楼cenlmmx(学海无涯苦作舟)回复于 2006-03-15 14:06:28 得分 10
这个基本没讨论的价值,没版本信息,没表的数据信息,哪种优化模式和执行计划...
Top




