Announcement

Collapse
No announcement yet.

Index Scan bei erwartetem Full table scan

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Index Scan bei erwartetem Full table scan

    Hallo zusammen,

    ich habe eine Tabelle mit ca. 1.000.000 Datensätze mit folgender Verteilung

    COUNT(V_STATUS) V_STATUS
    18708 V
    23696 R
    6954 P
    248 K
    50 D
    1492 B
    41299 Z
    874359 G
    60019 E
    1883 S


    Die Tabelle wurde analysiert mit

    [highlight=sql]analyze table tempmr
    compute statistics
    for columns v_status size 10[/highlight]

    [highlight=sql]select /*+ALL_ROWS*/ a.* from tempmr a where a.v_status='G'; [/highlight]

    Der CBO entscheidet sich grundsätzlich für einen Index-Scan
    Bei G mit fast 90% sollte er doch eher einfull Table scan machen, oder?
    Und ein Full table sollte doch auch scneller sein, nicht wahr?

    Vielen dank

    Gruß

    Martin

  • #2
    Analyse sollte man für diese Zwecke seit V9 nicht mehr verwenden, Du solltest statt dessen mit DBMS_STATS arbeiten.

    Ansonsten liegst Du mit Deiner Vermutung richtig.

    Dim
    Zitat Tom Kyte:
    I have a simple philosophy when it comes to the Oracle Database: you can treat it as a black box and just stick data into it, or you can understand how it works and exploit it as a powerful computing environment.

    Comment


    • #3
      Hallo Dim,

      danke Dir.
      Also kann es sein, dass es am 'analyse' liegt, dass dem CBO die Statistik egal ist!?

      Dann werde ich es mal mit dem Package versuchen.

      Nochmals danke

      Vile Grüße

      Martin

      Comment


      • #4
        Die Statistiken sind ihm nicht egal, nur erzeugt das dbms_stats Package bessere und auf den neuen CBO abgestimmte Statistiken.
        Mit diesem Aufruf werden auch Histogramme, sowie Statistiken für die zugehörigen Indices erzeugt:
        Code:
        BEGIN
        DBMS_STATS.GATHER_TABLE_STATS (
              OwnName        => 'Dein_Owner'
             ,TabName        => 'Deine_Tabelle'
            ,Estimate_Percent  => SYS.DBMS_STATS.AUTO_SAMPLE_SIZE
            ,Method_Opt        => 'FOR ALL INDEXED COLUMNS SIZE AUTO'
            ,Cascade           => TRUE);
        END;
        /
        Dim
        Zitat Tom Kyte:
        I have a simple philosophy when it comes to the Oracle Database: you can treat it as a black box and just stick data into it, or you can understand how it works and exploit it as a powerful computing environment.

        Comment


        • #5
          Hallo Dim,

          tausend dank.

          Gruß

          Martin

          Comment


          • #6
            Und mit deinen Statistiken greift der CBO auch, wie vorher von mir erwartet auf Index oder full scan.

            Wie gesagt, danke Dir!

            Martin

            Comment

            Working...
            X