国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

Oracle數(shù)據(jù)庫的大表,小表與全表掃描

2024-08-29 13:35:35
字體:
供稿:網(wǎng)友
  通常對于小表,Oracle建議通過全表掃描進(jìn)行數(shù)據(jù)訪問,對于大表則應(yīng)該通過索引以加快數(shù)據(jù)查詢,當(dāng)然假如查詢要求返回表中大部分或者全部數(shù)據(jù),那么全表掃描可能仍然是最好的選擇。
  從V$SYSSTAT視圖中,我們可以查詢得到關(guān)于全表掃描的系統(tǒng)統(tǒng)計(jì)信息: 
SQL> col name for a30
SQL> select name,value from v$sysstat
  2  where name in ('table scans (short tables)','table scans (long tables)');NAME                                  VALUE
------------------------------     ----------
table scans (short tables)            828
table scans (long tables)             101  其中table scans (short tables)指對于小表的全表掃描的此時(shí);table scans (long tables)指對于大表的全表掃描的次數(shù)。
  從Statspack的報(bào)告中,我們也可以找到這部分信息:Instance Activity Stats for DB: CELLSTAR  Instance: ora8i  Snaps:      20 -   

Statistic                                    Total   per Second    per Trans 
--------------------------------- ---------------- ------------ ------------ 
。。。。。。
table scan blocks gotten                38,228,349         37.0         26.9 
table scan rows gotten                 546,452,583        528.9        383.8 
table scans (direct read)                    5,784          0.0          0.0 
table scans (long tables)                    5,990          0.0          0.0 
table scans (rowid ranges)                   5,850          0.0          0.0 
table scans (short tables)               1,185,275          1.2           0.8 
  通常,假如一個(gè)數(shù)據(jù)庫的table scans (long tables)過多,那么db file scattered read等待事件可能同樣非常顯著,和以上數(shù)據(jù)來自同一個(gè)report的Top5等待事件就是如此:Top 5 Wait Events    
~~~~~~~~~~~~~~~~~                                    Wait     % Total
Event             Waits  Time (cs)   Wt Time
-------------------------------------------- ------------ ------------ -------
log file parallel write                         1,436,993    1,102,188   10.80
log buffer space                                   16,698      873,203    8.56
log file sync                                   1,413,374      654,587    6.42
control file parallel write                       329,777      510,078    5.00
db file scattered read                            425,578      132,537    1.30  數(shù)據(jù)庫內(nèi)部,很多信息和現(xiàn)象都是緊密相關(guān)的,只要我們加深對于數(shù)據(jù)庫的了解,在優(yōu)化和診斷數(shù)據(jù)庫問題時(shí)就能夠得心應(yīng)手?! racle通過一個(gè)內(nèi)部參數(shù)_small_table_threshold來定義大表和小表的界限。缺省的該參數(shù)等于2%的Buffer數(shù)量,假如表的大小小于該參數(shù)定義,Oracle認(rèn)為該表為小表,否則Oracle認(rèn)為該表為大表。
  我們看一下Oracle9iR2中的情況:SQL> @@GetParDescrb.sql
Enter value for par: small
old   6:    AND x.ksppinm LIKE '%&par%'
new   6:    AND x.ksppinm LIKE '%small%'NAME                    VALUE                DESCRIB
------------------------------ -------------------- ------------------------------------------------------------
_small_table_threshold         200                  threshold level of table size for direct reads
  以上數(shù)據(jù)庫中,200正好約為Buffer數(shù)量的2%:
SQL> show parameter db_cache_sizeNAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_cache_size                        big integer 83886080
SQL> select (83886080/8192)*2/100 from dual;(83886080/8192)*2/100
---------------------
                204.8  所以要區(qū)分大小表(Long/Short)是因?yàn)槿頀呙杩赡芤養(yǎng)uffer Cache的抖動,缺省的大表的全表掃描會被置于LRU的末端,以期盡快老化,減少Buffer的占用。從Oracle8i開始,Oracle的多緩沖池治理技術(shù)(Default/Keep/Recycle池)給了我們另外一個(gè)選擇,對于不同大小、不同使用頻率的數(shù)據(jù)表,從建表之初就可以指定其存儲Buffer,以使得內(nèi)存使用更加有效。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 石首市| 历史| 会理县| 和田县| 佳木斯市| 马边| 娄烦县| 偃师市| 依兰县| 兴文县| 江孜县| 拉萨市| 广宗县| 图们市| 扎鲁特旗| 玉林市| 垫江县| 桐梓县| 临高县| 武夷山市| 信丰县| 南投市| 蕉岭县| 南开区| 长垣县| 微博| 江油市| 屯昌县| 疏勒县| 鄂托克旗| 乐昌市| 泸西县| 潞城市| 乐都县| 凤凰县| 新乐市| 闽侯县| 遂溪县| 博客| 青河县| 道孚县|