千家信息网

Sql优化的大提升是什么

发表于:2025-02-19 作者:千家信息网编辑
千家信息网最后更新 2025年02月19日,Sql优化的大提升是什么,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。最近在做集团任务中心视图的优化 发现几个系统的sq
千家信息网最后更新 2025年02月19日Sql优化的大提升是什么

Sql优化的大提升是什么,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

最近在做集团任务中心视图的优化 发现几个系统的sql视图慢的过分 直接po代码 核心的业务sql 已蒙蔽

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

create or replace view km_todotasklist as

select "ID","DEVICE_TYPE","SYSTEM_TYPE","TASK_CODE","TASK_TYPE1","TASK_TYPE2","TITLE","STATUS","OWNER_ID","OWNER_NAME","PRIORITY","CREATE_ID","CREATE_TIME","UPDATE_ID","UPDATE_TIME" from

select t.id_ as id,

CASE

WHEN (select t.cfg_value from SYS_OT_CONFIG t where t.code ='SERVER_H5_MODELID' and INSTR( t.cfg_value ,a.module_id)>0 ) is null THEN

'PC,APP'

WHEN (select t.cfg_value from SYS_OT_CONFIG t where t.code ='SERVER_H5_MODELID' and INSTR( t.cfg_value ,a.module_id)>0 ) is not null THEN

'PC'

ELSE

(select t.cfg_value from SYS_OT_CONFIG t where t.code ='SERVER_H5_MODELID' and INSTR( t.cfg_value ,a.module_id)>0 )

END as device_type,

'KM' as system_type,

'核心业务URL'||utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw((select to_char(t.next_user_id_)

from OA_OT_PROCESS_RECORD t

where t.next_task_id_ = t.id_ and rownum=1)))) as task_code,

'代办' as task_type1,

to_char(mo.name) as task_type2,

to_char(a.title) as title,

'0' as status,

(select to_char(t.next_user_id_)

from OA_OT_PROCESS_RECORD t

where t.next_task_id_ = t.id_ and rownum=1) as owner_id,

(select em.real_name

from IMS_OT_USER t

inner join IMS_OT_EMPLOYEE em

on t.employee_id = em.id

where t.user_login_name =

(select t.next_user_id_

from OA_OT_PROCESS_RECORD t

where t.next_task_id_ = t.id_ and rownum=1) and rownum=1) as owner_name,

'' as priority,

a.creator as create_id,

a.create_time as create_time,

'' as update_id,

'' as update_time

from oa_ot_application a

inner join act_ru_task t

on t.proc_inst_id_ = a.pro_inst_id and t.task_def_key_ <> 'usertask2'

inner join oa_ot_application_ext et

on et.app_id = a.id and et.business_type ='1'

inner join OA_OT_APP_MODULE mo on a.module_id =mo.id

UNION ALL

select t.id as id,

'PC' as device_type,

'KM' as system_type,

'http://10.XX.XXX.XXX'||(select t.oa_req_url from OA_OT_APP_MODULE t where t.id =a.module_id)||'/input.htm?taskId='||t.id||'&appId='||a.id||'&sid='|| utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw(to_char(t.user_id)))) as task_code,

'待阅' as task_type1,

to_char(mo.name) as task_type2,

to_char(a.title) as title,

'0' as status,

to_char(t.user_id) as owner_id,

(select em.real_name

from IMS_OT_USER t

inner join IMS_OT_EMPLOYEE em

on t.employee_id = em.id

where t.user_login_name = t.user_id and rownum=1) as owner_name,

'' as priority,

a.creator as create_id,

a.create_time as create_time,

'' as update_id,

'' as update_time

from oa_ot_application a

inner join oa_ru_circulation t

on t.proc_inst_id = a.pro_inst_id

inner join oa_ot_application_ext et

on et.app_id = a.id

inner join OA_OT_APP_MODULE mo on a.module_id =mo.id

) t order by t.create_time desc;

全局查询大概15秒左右。

1 了解核心业务需求

2 了解目前sql痛点

3 改进sql

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

create or replace view km_todotasklist as

select t.id_ as id,

CASE

WHEN (select t.cfg_value from SYS_OT_CONFIG t where t.code ='SERVER_H5_MODELID' and INSTR( t.cfg_value ,a.module_id)>0 ) is null THEN

'PC,APP'

WHEN (select t.cfg_value from SYS_OT_CONFIG t where t.code ='SERVER_H5_MODELID' and INSTR( t.cfg_value ,a.module_id)>0 ) is not null THEN

'PC'

ELSE

(select t.cfg_value from SYS_OT_CONFIG t where t.code ='SERVER_H5_MODELID' and INSTR( t.cfg_value ,a.module_id)>0 )

END as device_type,

'KM' as system_type,

'核心业务URL'||utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw(re.next_user_id_))) as task_code,

'代办' as task_type1,

to_char(mo.name) as task_type2,

to_char(a.title) as title,

'0' as status,

re.next_user_id_ as owner_id,

emp.real_name as owner_name,

'' as priority,

a.creator as create_id,

a.create_time as create_time,

'' as update_id,

'' as update_time

from oa_ot_application a

inner join act_ru_task t

on t.proc_inst_id_ = a.pro_inst_id

inner join oa_ot_application_ext et

on et.app_id = a.id and et.business_type ='1'

inner join OA_OT_APP_MODULE mo on a.module_id =mo.id

left join OA_OT_PROCESS_RECORD re on re.next_task_id_ = t.id_

left join IMS_OT_USER uss on re.next_user_id_ =uss.user_login_name

left join IMS_OT_EMPLOYEE emp on uss.employee_id= emp.id;



目前sql已优化到0.3秒

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。

业务 核心 视图 需求 代办 帮助 清楚 代码 任务 全局 内容 对此 文章 新手 更多 痛点 知识 系统 行业 资讯 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 完美国际凤舞服务器 mysql数据库开发实例 吃鸡手游暗夜危机是哪个服务器 龙岗区口碑好的网络技术联系方式 苹果流览器无法连接到服务器 单招计算机网络技术要考什么 安徽正规软件开发价格有哪些 上位机软件开发合同模板 广东信创服务器生产厂商 微服务如何用数据库 网络安全创新规定 数据库主键使用什么好 服务器是否能安装安卓系统 计算机常见的网络安全威胁 关于手机网络安全的小品 渝中区软件开发专业 网络技术工作合同 深圳在线网络技术公司 数据库自动打印归档统计公式 虹口区散射网络技术售后保障 网络安全对国防建设的重要性 局域网组网首选的网络技术 怎样找到自己创建的数据库 oppo软件开发师工资 数据库技术应用有什么 服务器管理器批量添加用户 服务器驱动精灵安装不上 高拍仪直接传送到服务器 中国计算机网络技术史 谷歌上架服务器必须要同地区吗
0