Oracle CPU Costing
原文連線:
http://itspace.javaeye.com/blog/644780
[@more@]Oracle CPU Costing |
Turning on CPU Costing
The default setting for the optimizer cost model is CHOOSE, meaning that the presence of CBO statistics will influence whether or not CPU costs are considered. According to the documentation, CPU costs are considered when SQL optimizer schema statistics are gathered with the dbms_stat.gather_system_stats package, which is the default behavior in Oracle10g, and CPU costs will be considered in all SQL optimization.
It gets tricky because of Bug 2820066 where CPU cost is computed whenever optimizer_index_cost_adj is set to a non-default value. Unless the 9.2.0.6 server patch set has been applied, the Oracle9i database may be generating CPU statistics, regardless of the CBO stats collection method.
To ensure that CPU costing is in use:
§ In Oracle9i, use dbms_stats.gather_system_stats to collect statistics
§ Set the undocumented parameter _optimizer_cost_model=cpu;
Turning on I/O Costing
I/O-bound databases, especially 32-bit databases, may want to utilize I/O-based SQL costing. The default optimizer costing in Oracle10g is CPU, and it can be changed to IO costing by using these techniques:
§ Ensure that optimizer_index_cost_adj is set to the default value (Oracle9i bug 2820066)
§ Add a no_cpu_costing hint in the SQL
§ alter session set “_optimizer_cost_model=io;
§ Set init.ora hidden parameter _optimizer_cost_model =io
Notes on Bug 2820066:
CPU cost is computed when optimizer_index_cost_adj is set to a non-default value. If optimizer_index_cost_adj is set to a non-default value, CPU costs are calculated regardless of the optimizer cost model used. If optimizer_index_cost_adj is set and the optimizer CPU cost model is not in use, but the explain plan shows that for queries not using domain indexes CPU costs are being calculated, this bug is likely in play.
In sum, CPU cost is always computed regardless of optimizer mode when optimizer_index_cost_adj is set in unpatched Oracle versions less than 10.1.0.2.
The following section shows how to change from CPU-based to I/O-based SQL optimization when the processing characteristics of the database change on a regular basis.
--=================================
Hi all
I have an explain plan like below. and I doubt about the COST.
How is the COST be calculated? I mean what does that mean? (CPU
rate?)
SQL> @?/rdbms/admin/utlxpls.sql
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1764098166
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)|
Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 7824 (1)|
00:01:34 |
| 1 | SORT AGGREGATE | | 1 |
| |
| 2 | INDEX FAST FULL SCAN| BIG_TABLE_PK | 6812K| 7824 (1)|
00:01:34 |
------------------------------------------------------------------------------
The cost reported by the optimizer has always been a time estimate. It
just uses an odd unit which is single block reads. In your particular
case you see the overall cost is 7824 single block reads. The TIME
column tells you this cost turned into time by simply multiplying the
cost with the single block read time which is available if you have
System Statistics enabled (default from 10g on). We can deduce from
both the 94 seconds and the cost of 7824 that your average single
block read time according to your system statistics seems to be 12 ms
(94,000 ms / 7824 is quite close to 12 ms).
You can check your SYS.AUX_STATS$ table for the SREADTIM value - if it
is blank then you are running with (default) NOWORKLOAD System
Statistics and the single block read time is derived from IOSEEKTIM,
IOTFRSPEED and your default DB_BLOCK_SIZE.
The 12 ms are the default single block read time with default
NOWORKLOAD System Statistics and a default 8 KB default block size.
The % CPU is the estimated percentage of CPU cost of the calculated
cost, since with System Statistics the optimizer also includes an
estimation of the CPU cost required to execute the statement.
For more information, see e.g.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
Co-author of the "OakTable Expert Oracle Practices" book:
30226684
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1037218/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle CPU TIME 漫談Oracle
- SAP PM 入門系列之19 - IP31 Maintenance Plan CostingAINaN
- ORACLE CPU佔率高的程式Oracle
- oracle中WAIT TIME 和 CPU TIMEOracleAI
- 顯示 Oracle UNIX 程式的 CPU 和 RAMOracle
- 在windows上打Oracle的CPU補丁WindowsOracle
- oracle 高耗cpu sql語句的捕捉 。OracleSQL
- zt_Notes for Oracle Database PSU/CPUOracleDatabase
- ORACLE程式佔用CPU情況分析(轉載)Oracle
- cpu+wait for cpuAI
- Oracle CPU使用率過高問題處理Oracle
- Oracle CPU補丁包查詢下載的方法Oracle
- [Oracle] CPU/PSU補丁安裝詳細教程Oracle
- 檢視當前最消耗CPU/Memory的oracle程式Oracle
- oracle資料庫:耗cpu sql語句優化Oracle資料庫SQL優化
- oracle 11.1.0.6 版本中的resmgr:cpu quantum 等待事件Oracle事件
- oracle_CPU佔用率高時的問題定位Oracle
- oracle 並行cpu查詢分割槽表測試Oracle並行
- oracle 11g AWR CPU 顯示Bug 一則Oracle
- cpu+wait for cpu 到底是cpu空閒還是cpu不夠AI
- Oracle資料庫 11.2.0.4 EMON程式持續消耗CPUOracle資料庫
- oracle資料庫CPU特別高的解決方法Oracle資料庫
- Oracle優化案例-教你線上搞定top cpu的sql(十二)Oracle優化SQL
- Oracle補丁術語介紹 PSU CPU補丁Oracle
- Oracle DG/ADG上CPU/PSU補丁安裝Oracle
- oracle實驗記錄 (predicate對cpu cost的影響)Oracle
- ORACLE 系統統計資料和CPU開銷模型Oracle模型
- Oracle程式導致CPU 100%解決步驟(轉)Oracle
- Oracle效能優化-資料庫CPU使用率100%Oracle優化資料庫
- Oracle 補丁那些事兒(PS、PSU、CPU、SPU、BP、DBBP…)Oracle
- oracle 11g vktm程式佔用CPU高 【轉載】Oracle
- oracle實驗記錄 (sort_area_size與 cpu_time)Oracle
- 10g中佔用CPU很高異常oracle程式分析Oracle
- Linux下區分物理CPU、邏輯CPU和CPU核數Linux
- Oracle_10.2.0.5_for_Windows_Server_2008 CPU核數限制OracleWindowsServer
- 打Oracle最新CPU patch與打臨時補丁的區別Oracle
- oracle佔用os的cpu資源的多少算是健康的!Oracle
- oracle cpu(critical patch update)關鍵補丁更新集_官方網址Oracle