关于查询速度问题!谢谢
我有两个查询sql,一个查询的速度就很快,而另一个查询的非常慢,所查询出的数据都是大约4万条记录。想了一个上午也没有解决。哪位大哥帮帮我!谢谢
这个是快的
select t.login_user || '--' ||
(select k.user_name from user_t k where k.user_id = t.login_user) login_user,
t.tel,
t.aux_time,
t.aux_times,
t.zd_disconnect,
t.bd_disconnect,
to_char(t.login_time, 'yyyy-mm-dd hh24:mi:ss') login_time,
to_char(t.logout_time, 'yyyy-mm-dd hh24:mi:ss') logout_time,
t.talk_time
from seatstate_count_t t
where 1 = 1
and t.login_user not in ('0001', '0002', '0003')
and t.login_time between
to_date('2009-01-14 00:00', 'yyyy-mm-dd hh24:mi') and
to_date('2010-04-14 23:59', 'yyyy-mm-dd hh24:mi')
order by t.login_user, t.login_user, t.login_user
这个是慢的
select a.event_id,
b.dept deptid,
(select name from d_dept_tree_v t where t.deptid = b.dept) deptname,
a.event_code,
getdeptname(b.dept) receive_dept,
a.receive_user,
a.contact_tele,
a.call_tele,
(select code_value
from d_event_type_v v1
where v1.code_id = a.event_type) event_type,
a.call_owner,
caller,
to_char(a.call_time, 'yyyy-mm-dd hh24:mi') call_time,
a.place,
a.event_content,
v.code_id,
v.code_value,
f.*
from event_t a,
disposal_t b,
(select t.event_id,
nvl(t.other_type, 'other') other_type,
nvl(t.other_type2, 'other1') other_type2
from accident_info_t t) c,
(select * from d_disposal_state_v) v,
(select a.user_name, b.group_name, a.user_id, a.xh
from user_t_history a, user_group_t b
where b.group_code = a.group_code) f
where a.last_disposal_id = b.disposal_id
and a.event_id = c.event_id
and a.event_id = b.event_id
and b.state = v.code_id
and a.receive_user = f.xh
and a.call_time between
to_date('2009-04-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and
to_date('2009-04-15 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
and b.dept in
(53, 01, 0102, 0103, 0104, 0106, 02, 0202, 0203, 0204, 0206, 0207, 03, 0302, 0303, 04, 0402, 0403, 05, 0502, 0503, 0504, 0505, 0506, 0507, 0509, 06, 0602, 0603, 0604, 0605, 0607, 07, 0702, 0703, 0704, 0705, 0706, 08, 0802, 09, 0902, 0903, 0904, 10, 11, 12, 1202, 1203, 13, 14, 15, 16, 1602, 1604, 1605, 17, 18, 21, 22, 67, 91)
order by a.call_time,
b.state,
decode(deptid,
'53',
'0001',
'01',
'001',
'0102',
'00102',
'0103',
'00103',
'0104',
'00104',
'0106',
'00106',
'02',
'002',
'0202',
'00202',
'0203',
'00203',
'0204',
'00204',
'0206',
'00206',
'0207',
'00207',
'03',
'003',
'0302',
'00302',
'0303',
'00303',
'04',
'004',
'0402',
'00402',
'0403',
'00403',
'05',
'005',
'0502',
'00502',
'0503',