当前位置:网站首页>【达梦数据库】添加自动收集统计信息的任务
【达梦数据库】添加自动收集统计信息的任务
2022-07-06 19:54:00 【E-cology】
达梦数据库有个弱点,当查询数据量大时,查询速度变得非常慢,工程师一般都会去更新统计信息,但是用户不能时不时去手动去操作,所以做了一个定时作业,让系统定时去做。
—添加自动收集统计信息的任务(每周六1点收集全库统计信息),在SYSDBA用户下执行
SP_INIT_JOB_SYS(1); ----此语句如果报错,对象[SYSMAILINFO]已存在 等信息忽略就行,说明系统作业已经开启不影响
call SP_CREATE_JOB('statistics',1,0,'',0,0,'',0,'');
call SP_JOB_CONFIG_START('statistics');
call SP_ADD_JOB_STEP('statistics', 'statistics1', 0, 'begin for rs in (select ''sf_set_SESSION_para_value(''''HAGR_HASH_SIZE'''',(select cast( case when max(table_rowcount(owner,table_name))<=(select max_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') and max(table_rowcount(owner,table_name))>=( select min_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') then max(table_rowcount(owner,table_name)) when max(table_rowcount(owner,table_name))<( select min_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') then (select min_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') else (select max_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') end as bigint) from dba_tables where owner=''''''||NAME||''''''));'' sql1,''DBMS_STATS.GATHER_SCHEMA_STATS(''''''||NAME||'''''',100,TRUE,''''FOR ALL COLUMNS SIZE AUTO'''');'' sql2 from SYS.SYSOBJECTS where TYPE$=''SCH'' ) loop execute immediate rs.sql1; execute immediate rs.sql2; end loop; end;', 0, 0, 0, 0, NULL, 0);
call SP_ADD_JOB_SCHEDULE('statistics', 'statistics1', 1, 2, 1, 64, 0, '01:00:00', NULL, '2021-11-08 14:54:37', NULL, '');
call SP_JOB_CONFIG_COMMIT('statistics');
边栏推荐
- 杰理之发射端在接收端关机之后假死机【篇】
- Redis getting started complete tutorial: client management
- Lingyun going to sea | yidiantianxia & Huawei cloud: promoting the globalization of Chinese e-commerce enterprise brands
- C language string sorting
- 凌云出海记 | 易点天下&华为云:推动中国电商企业品牌全球化
- SQL中删除数据
- The first symposium on "quantum computing + application of financial technology" was successfully held in Beijing
- netperf 而网络性能测量
- Andrews - multimedia programming
- Es6中Promise的使用
猜你喜欢
Django database (SQLite) basic introductory tutorial

左程云 递归+动态规划

2022 spring recruitment begins, and a collection of 10000 word interview questions will help you

Es6中Promise的使用

ERROR: Could not find a version that satisfies the requirement xxxxx (from versions: none)解决办法

Redis入门完整教程:复制配置

密码学系列之:在线证书状态协议OCSP详解
![[tools] basic concept of database and MySQL installation](/img/9c/626e42097050517a13a2ce7cdab1bb.jpg)
[tools] basic concept of database and MySQL installation

uniapp适配问题

How to analyze fans' interests?
随机推荐
Redis getting started complete tutorial: replication topology
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (initial assignment part)
Don't you know the relationship between JSP and servlet?
Redis入门完整教程:客户端案例分析
知识图谱构建全流程
[socket] ① overview of socket technology
Unity使用MaskableGraphic画一条带箭头的线
netperf 而网络性能测量
MySQL is an optimization artifact to improve the efficiency of massive data query
Netperf and network performance measurement
Construction of knowledge map of mall commodities
Development of wireless communication technology, cv5200 long-distance WiFi module, UAV WiFi image transmission application
Redis getting started complete tutorial: common exceptions on the client
【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】
【安全的办公和生产力应用程序】上海道宁为您提供ONLYOFFICE下载、试用、教程
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (time synchronization part)
又一百万量子比特!以色列光量子初创公司完成1500万美元融资
从0开始创建小程序
HDU 4337 King Arthur&#39;s Knights 它输出一个哈密顿电路
[swift] learning notes (I) -- familiar with basic data types, coding styles, tuples, propositions