oracle 物化视图查询慢,为何用户物化视图后查询比之前的慢了

select

s.recipe_cate_text,

sum(s.all_dosing_recipe) all_dosing_recipe_count,

sum(s.is_cancel_dosing_recipe) cancel_dosing_recipt_count,

sum(s.all_dosing_recipe) - sum(s.is_cancel_dosing_recipe) dosing_recipe_count,

sum(case when s.state=2 then s.amount else 0 end) dosing_recipe_money,

s.clinic_dept_code,

max(s.clinic_dept_text) clinic_dept_text

from (

select (

select

max(mvdrug.drugcategorytext)

from

OUTPATIENT_RECIPE_DETAIL rd

left join mv_drugcategory mvdrug on rd.durg_id = mvdrug.drug_info_id

/*

left join oms_drug_info drug on rd.durg_id = drug.drug_info_id

left join oms_drug_category drug_cat on drug.drug_category_id = drug_cat.drug_category_id

*/

where

rd.recipe_id = r.recipe_id

) recipe_cate_text,

case when r.state in (2,3) then 1 else 0 end all_dosing_recipe, -- 所有已投药处方

case when r.state = 3 then 1 else 0 end is_cancel_dosing_recipe, -- 已退药处方

r.state,

r.amount,

d.code clinic_dept_code,

d.text clinic_dept_text

from

outpatient_recipe r

left join outpatient_registration g on r.registration_id = g.registration_id

left join oms_general_dept d on g.dept = d.general_dept_id

where

r.is_del = 0

and r.state in (2,3) -- 已投药,已退药

and r.dosing_time >= to_date('2013-01-24 00:00:00','yyyy-mm-dd hh24:mi:ss')

and r.dosing_time <= to_date('2013-06-24 23:59:59','yyyy-mm-dd hh24:mi:ss')

and r.dosing_dept2 =  '51c6013d-ef8c-4b98-bd60-fac1c2b40db8'  ) s

group by s.clinic_dept_code, s.recipe_cate_text

order by s.clinic_dept_code, s.recipe_cate_text;

这是更改的的查询

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值