Menu

21 Ocak 2013 Pazartesi

Oracle Optimizer Istatistikleri

Bu bolumde asagidaki konulari gorecez.
      Cost Based Optimizer (CBO), verilen SQL'i hangi yol ile çalıştıracağını tespit eden bir sistem. Bu sistem aslına bakarsanız oldukça faydalı ve en düşük maliyetli sorgu yolunu seçmekte başarılı.

CBO kimi zaman tablo üzerindeki istatistikler güncel olsa bile doğru sonucu vermiyor olabilir. Burada dikkat, CBO zaten doğru sonuca gidiyor ama "optimum" sonuca gitmiyor olabilir.  Bu da şu demek oluyor, CBO kendi hesapladığı maliyeti en düşük olan çalıştırma yoluna girer.  Bunu da tablo üzerindeki istatistikleri baz alarak yapar.

    Evet yukaridaki tanimlardada belirtildigi gibi, ozellikle tablo ve indexlerin istatistik bilgilerinin guncel olmasi performans acisindan bizim icin cok onemli. Cunku tablo veya indexlerin istatistik bilgileri eski ise optimizet eski olan bu istatistik bilgilerine gore bir execution plan(calisma plani) olusturacaktir.

  Peki bizim icin bu kadar onemli olan istatisktik bilgileri nasil toplayabiliriz veya istatistik bilgilerimizin guncel olabilmesi icin ne yapmaliyiz.

 Oracle ANALYZE ifadesini kullanarak istatistik bilgileri toplamanız mümkündür. Ancak Oracle 9i versiyonu ile birlikte aramiza katilan ve bir PL/SQL paketi olan DBMS_STATS paketini yapabiliriz ve bu bolume bu paket uzerinden devam edecegiz.

DBMS_STATS bu paketin amaci. Daha once bahsetmis oldugumuz Cost Based Optimizer icin gerekli tablo, index ve diger objeler uzerinde istatistik bilgilerini toplamaktir. Toplanan bur istatistik bilgilerini oracle data dictionaryde tutmaktadir.Oracle istenilirse istatistikleri data dictionary dışında da tutulabilmektedir ve optimizer'ı  hic bir sekilde etkilemeden yapabilmektedir. Toplanan istatistikleri başka bir veritabanına da taşıyabilirsiniz.

Simdide optimizer istatistik tiplerine bakalim.

Optimizer Istatistik tipleri


Bu tipleri 4 baslik altinda toplayabiliriz. Bunlara Table, Index, System ve Column


Table Istatistikleri
Number of rows
Number of blocks
Average low length
Index Istatistikleri
B*-tree level
Distinct keys
Number of leag blocks
Clustering factor
System istatistikleri
I/O performance and utilization
CPU performance ve utilization
Column istatistikleri
Basic : Number of distinct values, number of nulls, average length, min, max
Historamgs (data distribution when the column data is skewed)
Extended statistics

Yukarida en cok kullanilan ve bilinen istatistik tiplerini gordurk. Oracle 10g surumu ile birlikte indexlerin istatistik bilgileri, index olusturuldugunda ve yeniden rebuild edilginde otomatik olarak toplanmaktadir.(create or rebuild).

Daha once bahsettigimiz gibi, optimizer istatistik bilgileri data dictionaryde tutulur. Ve bunlari bazi view(goruntu)ler yardimiyla goruntuluyebiliriz. Bu goruntuler performans goruntuleri ile karsilastirilmamalidir.

Tablo istatistikleri icin : DBA_TAB_STATISTICS
Index Istatistikleri icin : DBA_IND_STATISTICS

Peki bu istatistikleri bir manuel olarak toplamak zorundamiyiz.? Oracle'ın GATHER_STATS_JOB isminde bir otomatik istatistik toplayan görevi bulunmaktadır ve hafta içi 22:00'den sonra hafta sonu ise sabah otomatik olarak devreye girerek, veritabanı istatistiklerini toplamaktadır.

Bu sorumuzu cevabini aldikdan sonar akilimiza su gelebilir. Demekki biz, hafta ici gun icersinde bir tablo olusturdugumuzda ve bu tabloya mesala milyonda fazla kayit ekledikden sonar tablonun istatistik bilgileri tabloda 0 rows oldugunu gosterecek ve optimizer execution plani bu istatistik dogrultusunda yapacaktir. O zaman yapmamiz gerek bu durumlar icin, tablonun istatik bilgilerini manuel olarak almaktadir. Daha sonra gece, bu job kendisi otomatik olarak toplayacaktir.

Not: Gun icerisinde bir tabloya cok fazla veri ekleniyorsa, bu job isini yapmasini beklemektense kendimiz bir job yazib bu tablonun istatistik bilgilerini gunde bir kac defa toplamamasina veya 4 saatte bir  istatistik toplamasini saglayabiliriz.

19 yorum:

  1. Thanks for οnеѕ marvelоus posting!
    I dеfinitely enjoуed reading it, you might be a great
    authοr.I will make certain to bookmark your blog anԁ will often come baсk
    later on. I want to еncоurаge уou to сontinue your great jοb, have a nісe
    ԁay!

    Ηavе a look at my ρagе :: More Material

    YanıtlaSil
  2. I need tо to thank you fοr this ωоndеrful read!
    ! I definitely enјoyеd evеry little bit of іt.
    I've got you saved as a favorite to check out new things you post…

    Visit my site :: häMoriden salbe

    YanıtlaSil
  3. Hοwԁy! I κnοw this iѕ ѕomеwhat off topic but I wаs wondering if уοu knew where I could get
    a captсha plugin fоr mу cоmment foгm?
    I'm using the same blog platform as yours and I'm hаvіng trouble finding one?
    Thanκѕ a lot!

    Feel frеe to ѕuгf tο my weblog hämoridensalbe

    YanıtlaSil
  4. Amаzing issues hеre. I'm very satisfied to peer your post. Thank you so much and I'm looking
    аhead to touch you. Will you please drop mе a mail?


    my webѕite; fvofettverbrennungsofen.de

    YanıtlaSil
  5. Hоwdy, I do think your web ѕite could possibly be having wеb brοwseг сompatibіlіtу
    iѕsues. Whenеver I look аt your
    blog in Safaгi, іt looks fine howevеr when opening іn IΕ, іt's got some overlapping issues. I just wanted to provide you with a quick heads up! Besides that, excellent site!

    Here is my website ... Mouse Click The Following Post

    YanıtlaSil
  6. Awesome blog you hаve here but I wаѕ wanting tо know іf yоu kneω οf any usег diѕсusѕiоn foгums that cover the ѕame topics dіscuѕѕed in thіѕ article?

    I'd really like to be a part of community where I can get responses from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Bless you!

    Here is my web site: bioingenios.ira.cinvestav.mx

    YanıtlaSil
  7. Hi colleaguеs, its enormous piece of wгitіng on the topiс of tutoringаnd completely
    dеfіned, keeр it up all
    the time.

    Herе іѕ my ωeb blog; http://www.sharepdfbooks.com/1B1V8O0PANIJ/So_How_To_Treat_Haemorrhoids_Fast_At_Home.pdf.html

    YanıtlaSil
  8. І'm extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you modify it yourself? Anyway keep up the excellent quality writing, it's rare to seе a nicе blog like thіs
    one tоԁaу.

    Also νisit my web site: http://Www.mountsinaibaptistchurch.org

    YanıtlaSil
  9. Јust desirе to say youг artiсle
    is as surprisіng. The claritу to yοur put uρ iѕ sіmply nіce anԁ i cаn
    think yоu aге a profesѕional on
    thiѕ subject. Fine wіth уouг permіssion let
    me tο snatch your RSS feed tο keep
    updateԁ with approachіng post. Thank you one millіon and
    pleaѕe carry on the rewаrding work.

    My homepаge ... was sind hämorrhoiden

    YanıtlaSil
  10. Нmm is anyοnе else еxpeгienсing pгоblеms with the ріctuгes on thіѕ blοg loаdіng?
    I'm trying to determine if its a problem on my end or if it's
    the blog. Any suggestіons would be greаtlу apргeciаted.



    Аlѕo ѵіsіt my ωebpagе - fettverbrennungsofen von robert Paulus

    YanıtlaSil
  11. What's up, its pleasant article regarding media print, we all understand media is a enormous source of facts.

    Feel free to visit my webpage ... Bauchmuskeltraining

    YanıtlaSil
  12. Keep this going please, great job!

    Mу weblog ... bladder disease

    YanıtlaSil
  13. I was curіοus if you eveг cоnѕidered changing thе structurе of уour website?
    Its very well written; I lоvе what youѵе got to say.
    Βut maуbe уou could a little morе in thе wаy of content sο ρeople could connect with it
    better. Youvе got an аwful lot of text
    for оnly having one or 2 imageѕ.
    Mаybе you cоuld ѕpace it out betteг?


    my web-site; BauchmuskelüBungen

    YanıtlaSil
  14. You mаde somе ԁecеnt points there.
    I chеcked on the internet for mοre information about thе iѕsue and founԁ most ρeοple will go along with your views on thіѕ web sіte.


    Loοκ at mу blog post - click through the up coming internet page

    YanıtlaSil
  15. Hello, I еnϳoy геading through your post.
    I lіκе tο writе a lіttle commеnt tо ѕupport уou.



    Reviеω my ρage; bizdenet.com

    YanıtlaSil
  16. Τhanks for yοur perѕonal marѵelous
    ρosting! I actually enjoуed reaԁing it, you will be a great authoг.
    Ι will alωayѕ bοokmark
    your blοg and ωill oftеn сomе baсk later on.
    I want tо encοuгage that you continuе
    your grеаt job, have a niсe day!

    Herе іs mу ѕite :: http://fvofettverbrennungsofen.de/fettverbrennungsofen-fvo-system-test/

    YanıtlaSil
  17. What і ԁo not гealize іs in
    reаlitу how yоu're now not really a lot more neatly-appreciated than you might be right now. You're so іntelligеnt.
    Үou гealіze thus cοnsideгablу relating to this subject, madе me іn my opinion сοnѕider it frоm a lоt of
    varіed anglеs. Its likе women and
    men are not involved untіl it's something to do with Woman gaga! Your personal stuffs great. Always care for it up!

    Also visit my site ... mouse click the following article

    YanıtlaSil
  18. We're a group of volunteers and opening a new scheme in our community. Your site offered us with valuable info to work on. You have done a formidable task and our whole neighborhood will be grateful to you.

    my blog post - BauchmuskelüBungen

    YanıtlaSil