Following query giving DB CPU utilization impact, can I reduce data in table will help me to reduce DB CPU performance

前提是你 提交于 2019-12-23 05:25:36

问题


I am using following query in which , table which is being referred that have 50Million+ records. By creating history table will help me out to better CPU performance ? or is there any other option apart from Partition. Or Query plan tweak is the only option ?

SELECT MIN(minbkt),
       maxbkt,
       SUBSTRB(DUMP(MIN(val), 16, 0, 32), 1, 120) minval,
       SUBSTRB(DUMP(MAX(val), 16, 0, 32), 1, 120) maxval,
       SUM(rep) sumrep,
       SUM(repsq) sumrepsq,
       MAX(rep) maxrep,
       COUNT(*) bktndv,
       SUM(CASE
               WHEN rep = 1 THEN
                1
               ELSE
                0
           END) unqrep
  FROM (SELECT val,
               MIN(bkt) minbkt,
               MAX(bkt) maxbkt,
               COUNT(val) rep,
               COUNT(val) * COUNT(val) repsq
          FROM (SELECT
                /*+ no_parallel(t) no_parallel_index(t) dbms_stats cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring */
                 "VERSION_LABEL" val,
                 NTILE(75) OVER(ORDER BY NLSSORT("VERSION_LABEL", 'NLS_SORT = binary')) bkt
                  FROM "User"."AUDITTRAIL" t
                 WHERE "VERSION_LABEL" IS NOT NULL)
         GROUP BY val)
 GROUP BY maxbkt
 ORDER BY maxbkt

回答1:


It looks like this is a query associated with gathering a histogram on the version_label column of an auditing table.

I would expect that you almost certainly do not need such a histogram to be present, and you can modify the statistics gathering to just collect simple statistics on such a table -- ie. no histograms. the best way of doing that would be based on your version and the way in which the statistics gathering is being triggered, but if you need help with that then either expand the question to include those details or start another question.



来源:https://stackoverflow.com/questions/15378075/following-query-giving-db-cpu-utilization-impact-can-i-reduce-data-in-table-wil

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!