• Oracle 搜集统计信息的存储过程


    DECLARE
      CURSOR STALE_TABLE IS
        SELECT OWNER,
               SEGMENT_NAME,
               CASE
                 WHEN SIZE_GB < 0.5 THEN
                  30
                 WHEN SIZE_GB >= 0.5 AND SIZE_GB < 1 THEN
                  20
                 WHEN SIZE_GB >= 1 AND SIZE_GB < 5 THEN
                  10
                 WHEN SIZE_GB >= 5 AND SIZE_GB < 10 THEN
                  5
                 WHEN SIZE_GB >= 10 THEN
                  1
               END AS PERCENT,
               8 AS DEGREE
          FROM (SELECT OWNER,
                       SEGMENT_NAME,
                       SUM(BYTES / 1024 / 1024 / 1024) SIZE_GB
                  FROM DBA_SEGMENTS
                 WHERE OWNER = 'ADWU_OPTIMA_AP11'
                   AND SEGMENT_NAME IN
                       (SELECT /*+ UNNEST */
                        DISTINCT TABLE_NAME
                          FROM DBA_TAB_STATISTICS
                         WHERE (LAST_ANALYZED IS NULL OR STALE_STATS = 'YES')
                           AND OWNER = 'ADWU_OPTIMA_AP11')
                 GROUP BY OWNER, SEGMENT_NAME);
    
    BEGIN
      DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO;
      FOR STALE IN STALE_TABLE LOOP
        DBMS_STATS.GATHER_TABLE_STATS(OWNNAME          => STALE.OWNER,
                                      TABNAME          => STALE.SEGMENT_NAME,
                                      ESTIMATE_PERCENT => STALE.PERCENT,
                                      METHOD_OPT       => 'for all columns size repeat',
                                      DEGREE           => 8,
                                      GRANULARITY      => 'ALL',
                                      CASCADE          => TRUE);
      END LOOP;
    END;
    /

  • 相关阅读:
    索引
    varnish它是一款高性能的http缓存服务器
    前端性能优化浅谈
    锁机制-SQL Server 数据库
    NET Core中NuGet包
    “干掉” if...else
    混搭.NET技术
    MONO x64 amd_x64
    跨平台移动开发UI语言 -XAML
    使用LinqToExcel读取Excel
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13352429.html
Copyright © 2020-2023  润新知