Index Rebuild. DOAG Konferenz , Nürnberg DOAG Konferenz , Nürnberg Martin Hoermann Martin Hoermann

Ähnliche Dokumente
Index Rebuild. DOAG Konferenz , Nürnberg. Martin Hoermann

Oracle Database 12c Was Sie immer schon über Indexe wissen wollten

Performance in der Oracle Datenbank von Anfang an

DOAG Index Tuning

Oracle 9i Einführung. Performance Tuning. Kurs. Teil 8 Indizes. Universität Hannover. Installation. Index-Typen. Anhang.

Oracle Index Tuning &Admin

Oracle 9i Einführung Performance Tuning

10 Gründe warum Ihr Index nicht verwendet wird

Partitionierung Indizes und Statistiken

einfach. gut. beraten. Stabilisierung von Ausführungsplänen Baselines DOAG Konferenz + Ausstellung 2017 Nürnberg Klaus Reimers

DOAG Regionaltreffen TABLE REORG. Klaus Reimers. Leiter Beratung & Entwicklung, ORDIX AG, Paderborn

Willkommen zum DOAG Regionaltreffen

SQL-Tuning auf RAC Piraten des Interconnects

Tabellen und Indizes Reorganisieren, aber wann?

Johannes Ahrends Geschäftsführer CarajanDB GmbH CarajanDB GmbH

Der Ausführungsplan das unbekannte Wesen

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Warum wird mein Index nicht benutzt?

Automatisierung von Tabellen- und Index-Reorganisationen

SQL on RAC Pirates of the interconnect

Flashback mal sieben. DOAG Konferenz , Nürnberg. Klaus Reimers

Tuning the Mobile Server

Gliederung. 1) Speicherplatz-Zuordnung und -Verwaltung 2) Indizes 3) Explain Plan 4) Join-Operationen 5) Der Optimizer 6) Parallelisieren

Inhalt. 1. Indextypen B*Baum-Index Reversed Key Index Bitmap Index Funktionsbasierter Index

Row Chaining & Row Migration Alte Bekannte - immer noch aktuell! DOAG 2014 Datenbank Dierk Lenz

Oracle Indexing Primer

Oracle 9i Einführung Performance Tuning

DOAG Nürnberg Oracle Index Tuning & Administration. Marco Patzwahl

Datenbank Reorganisation Sinn oder Unsinn?

Ich liebe es, wenn ein Plan funktioniert

Fast Analytics on Fast Data

Manuelles Oracle SQL Tuning

ZWISCHEN ALBTRAUM UND OPTIMALER PERFORMANCE

Indizes B+Bäume in Oracle. Jörg Winkler

Oracle 9i Einführung. Performance Tuning. Kurs. Teil 10 Stored Outlines. Universität Hannover. Eigenschaften. Migration. Erstellen mit OEM.

Oracle Tuning - Theorie und Interpretation

MySQL Architektur die Admin-Sicht

DOAG RAC Optimierung im Siebel CRM Umfeld. Dipl.-Inform. Frank Beutelschiess

Performance-Prognosen im Test, trotz Datenschutzauflagen. Daniel Stein. DOAG November 2016

Acht große Oracle-Datenbank-Mythen

DOAG Konferenz Was Sie bei modernen Datenbank-Systemen anders machen müssen!

Anfrageoptimierung Ausführungspläne, Hints, Statistikinformationen, IDEs

Index-Reorganisationen Mythen und Fakten. Michael A. Istinger EDV-Beratung Istinger

Optimiertes Laden in die F-Fakten-Tabelle des SAP BW

Objektorientierung in Oracle

Nutzung der Oracle Database InMemory Option für SAP BW

Indexbasiertes SQL Tuning

Shaping the Future of Intelligence. PLATH Group 1

Memory-Drilldown von der SGA über die PGA zum Database Buffer Advisor

Kerberos und das Oracle Die Nutzung von Kerberos in einer Solaris-Oracle-Umgebung

Performance Tuning mit Oracle 12c

MIN oder MAX Bildung per B*Tree Index Hint

Oracle 10g Einführung

einfach. gut. beraten. Oracle Big Data Konnektoren: Hadoop und die Oracle DB DOAG Konferenz + Ausstellung 2016 Nürnberg Philipp Loer

Oracle Datenbank Reorganisationen

Datenbank-Tuning. Folien zum Datenbankpraktikum Wintersemester 2009/10 LMU München

INDEXIERUNGS- STRATEGIE IM DATA WAREHOUSE

Partitionierung Indizes und Statistiken

Hysterie um Histogramme

Grundlagen der Datenbanksysteme 2 (M-DB2) Dr. Karsten Tolle

Oracle Datenbank - Tuning

Johannes Ahrends Geschäftsführer CarajanDB GmbH

Indexing und Performance Tuning

Oracle Old Features. Vortrag für die DOAG-Konferenz Uwe M. Küchler, Valentia GmbH

Partitioning Technik und Anwendungsbeispiele

Systematische Rasterfahndung nach Performance-Antipattern

DOAG SIG Data Warehouse & Business Intelligence. Praxisbericht DWH mit 5 Milliarden Fakten

Nützliche Oracle 12c Features für Data Warehousing DOAG BI, 8. Juni 2016 Dani Schnider, Trivadis AG

MySQL für Oracle DBAs

ORACLE DATENBANKOPTIMIERUNG (BASICS)

Oracle 9i Einführung Performance Tuning

Johannes Ahrends CarajanDB GmbH CarajanDB GmbH

Datenversionierung in Business-Anwendungen

Auditing Sinn, Einsatzmöglichkeiten und Performance

Oracle Datenbank 11g Advanced Compression Option

Explain verstehen. Hans-Jürgen Schönig.

Übung PL/SQL Trigger Lösungen

Vorstellung DIE QSC AG. Datum:

3. Architektur eines DBS (Oracle)

Speicherung und Verarbeitung von Geodaten mit Oracle Spatial

Die Vielfalt von Bitmap-Indizes im DWH

Sicheres Identifizieren von nicht relevanten Indizes. Peter Ramm, OSP Dresden

Oracle 12c: Neuerungen in PL/SQL. Roman Pyro DOAG 2014 Konferenz

IBM Informix Tuning und Monitoring

SQL Optimizer und SQL Performance

DOAG Konferenz + Ausstellung 2017 Nürnberg Michael Skowasch

Extreme Performance mit Oracle Times Ten

Speed up your Query Strategien zur Optimierung von SQL-Queries. Juni 2012 Ulrike Brenner

Query Result Caching. Optimierung des Datenbankzugriffs

PostgreSQL Wartungsstrategien

Hochverfügbarkeit mit Data Guard Möglichkeiten und Grenzen

Anwendungsentwicklung Datenbanken SQL. Stefan Goebel

4. Aufgabenblatt - Auswertung -

Oracle Old Features. Uwe Küchler Valentia GmbH Frankfurt am Main

Datenbanken II B: DBMS-Implementierung Klausur

Ganzheitliche Optimierung

6. Anfragebearbeitung

Performanter Aufbau von Materialized Views im ETL-Prozess Vorgehen und ein Framework für den OWB. Reinhard Mense Geschäftsführer ARETO Consulting

Transkript:

Index Rebuild DOAG Konferenz 17.01.2011, Nürnberg DOAG Konferenz 17.11.2011, Nürnberg Martin Hoermann info@ordix.de Martin Hoermann www.ordix.de info@ordix.de www.ordix.de

Eine kurze Geschichte der Zeit Eine kurze Geschichte der (Oracle) Zeit, Martin Hoermann 1 / 51

Big Ben DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 2

Index Rebuild DOAG Konferenz 17.01.2011, Nürnberg DOAG Konferenz 17.11.2011, Nürnberg Martin Hoermann info@ordix.de Martin Hoermann www.ordix.de info@ordix.de www.ordix.de

www.dba-oracle.com Quelle: www.dba-oracle.com/t_index_rebuilding_indexes.htm DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 4

asktom.oracle.com Quelle: asktom.oracle.com/pls/asktom/f?p=100:11:745954239666467::::p11_question_id:2913600659112 DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 5

Richard Foote - Index Internals Quelle: http://richardfoote.files.wordpress.com/2007/12/index-internals-rebuilding-the-truth-ii.pdf DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 6

DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 7

Es gibt zwei Kategorien von Menschen. Die einen, die den Strick um den Hals haben und die anderen, die ihn abschneiden. Zwei glorreiche Halunken DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 8

Agenda Index-Strukturen Basisbegriffe Zugriffsstrategien Abgrenzung Testszenarien Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 9

Branch- und Leaf-Blocks Root Block... Branch Block 10 18 v$index_stats.height = dba_indexes.blevel + 1 Leaf Block 2 4 10 12 14 16 18 20 22 50% 100% 90% Füllgrad Key + ROWID = NULL DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 10

leaf node splits 10 18 2 4 6 8 10 12 14 16 INSERT 5 INSERT 17 6 10 17 2 4 5 6 8 10 12 14 16 17 leaf node splits leaf node 90-10 split DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 11

branch node split 6 10 18 Row-ID des root Blocks bleibt identisch 2 4 5 6 8 10 12 14 16 18 20 22 24 INSERT 17 branch node splits 16 6 10 16 18 2 4 5 6 8 10 12 14 16 17 18 20 22 24 DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 12

Agenda Index-Strukturen Basisbegriffe Zugriffsstrategien Abgrenzung Testszenarien Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 13

Index Unique Scan 6 10 18 2 4 5 6 8 10 12 14 16 18 20 22 24 SELECT /*+ INDEX(...) */ * FROM my_table WHERE id = 20; = blevel + 1 (leaf) [ + table access ] DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 14

Index Range Scan Ausgabe sortiert 6 10 18 2 4 5 6 8 10 12 14 16 18 20 22 24 SELECT /*+ INDEX_RS_ASC(...) */ * FROM my_table WHERE id BETWEEN 8 AND 20; = blevel + n ( Anzahl leaf) [ + table access je row ] DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 15

Index Full Scan Ausgabe sortiert 6 10 18 2 4 5 6 8 10 12 14 16 18 20 22 24 SELECT /*+INDEX_FS(...) */ * FROM my_table WHERE id > 0; = blevel + leaf blocks [ + table access je row ] DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 16

Index Fast Full Scan db_file_multiblock_read_count Ausgabe nicht sortiert Bitmap Freelist Bitmap Freelist Segment Header 6 10 18 10 12 14 16 25 2 4 5 6 8 18 20 22 24 SELECT /*+ INDEX_FFS(...) */ * FROM my_table WHERE id > 0; = # Blöcke im Segment [ + table access je row ] DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 17

Sonstige Zugriffstrategien Index Skip Scan Range Scan Desc Index Join Bitmap Index DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 18

Agenda Index-Strukturen Basisbegriffe Zugriffsstrategien Abgrenzung Testszenarien Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 19

Abgrenzung Index Typen + Zugriffe Function Based Index Index Joins Bitmap Indizes Reverse Indizes Kosten Cost Based Optimizer Locks & Latches DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 20

Agenda Index-Strukturen Testszenarien Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 21

Agenda Index-Strukturen Testszenarien Nur Inserts Primary Key Index Index mit 1% Selektivität Index mit normalverteilter Selektivität Insert + Delete B-Level Optimierung Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 22

Test nur Insert 1. Durchlauf 2. Durchlauf 10 Millionen Sätze Rebuild Delta Ermittlung für 100.000 Insert Block Splits 100.000 Insert Anzahl Leaf Blocks 900.000 Insert Redo Volumen CPU-Zeit 900.000 Insert Consistent Gets 4.000.000 Insert 4.000.000 Insert DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 23

Varianten Primary Key Index über Sequenz doag_data.nextval 1 Prozent Selektivität, Gleichverteilt mod( doag_data_seq.currval, 100 ) Normalverteilung trunc( dbms_random.normal() * 10000 ) DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 24

Agenda Index-Strukturen Testszenarien Nur Inserts Primary Key Index Index mit 1% Selektivität Index mit normalverteilter Selektivität Insert + Delete B-Level Optimierung Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 25

PK-Index über Sequenzen 5 9 1 2 3 4 5 6 7 8 9 10 11 12 INSERT 13 5 9 13 1 2 3 4 5 6 7 8 9 10 11 12 13 Index 90:10 Split DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 26

Rebuild DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 27

Primary Key Index nach Rebuild 5 9 13 1 2 3 4 5 6 7 8 9 10 11 12 13 Rebuild 10 4 7 10 13 1 2 3 4 5 6 7 8 9 10 11 12 13 PCT_FREE = 90% DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 28

Rebuild Effects Mehr Leaf Blocks PCT-Used wird bei streng monoton steigenden Werten nie wieder genutzt PCT-Used = 0 % entspricht Aufbau wie zuvor Augenscheinlich ist es unsinnig Primary Key Indizes zu reorganisieren.* * für das Szenario Insert ohne Delete DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 29

Primary Key Index bei RAC Was passiert bei RAC bei Sequenzen mit Cache? DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 30

Agenda Index-Strukturen Testszenarien Nur Inserts Primary Key Index Index mit 1% Selektivität Index mit normalverteilter Selektivität Insert + Delete B-Level Optimierung Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 31

Index 1 % Selektivität Bei vielen Daten viele Wiederholungen Daten werden im Index sortiert nach Row-ID eingefügt 9 9 9 9 9 9 9 9 9 9 9 Ausschnitt für einen Wert! DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 32

Rebuild DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 33

Index 1 % Selektivität: Rebuild 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 Ausschnitt für einen Wert! DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 34

Index 1 % Selektivität: Fazit I weniger Leaf Blöcke (bis zu 50%) Für vorhandene Index-Blöcke nachhaltig Besseres Caching Index Read Only oft deutlich schneller! DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 35

Index 1% Selektivität: Fazit II Ohne Rebuild Clustering Factor: 3.179.374 Leaf Blocks: 24.700 Kosten: ~ 3.204.000 Mit Rebuild Clustering Factor: 3.179.374 Leaf Blocks: 14.900 Kosten: ~ 3.194.000 Kostendifferenz für Full Scan: 0,31% weniger Blockzugriffe DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 36

Index 1% Selektivität: Clustering Factor mod( seq.currval, 100 ) 0 1 2 3 4 99 0 1 2 3 4.. 1 1 1 1 1 mod( trunc( seq.currval / 100 ), 100 ) 0 0 0 0 0 1 1 1 1. 1 2 2 2 2 1 1 1 1 1 DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 37

Index 1% Selektivität: Fazit III Ohne Rebuild Clustering Factor: 132.331 Leaf Blocks: 26.000 Kosten: ~ 158.000 Mit Rebuild Clustering Factor: 132.331 Leaf Blocks: 15.400 Kosten: ~ 147.000 Kostendifferenz für Full Scan: 7% weniger Blockzugriffe DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 38

Agenda Index-Strukturen Testszenarien Nur Inserts Primary Key Index Index mit 1% Selektivität Index mit normalverteilter Selektivität Insert + Delete B-Level Optimierung Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 39

Index Normalverteilung Aufbau Normalverteilung trunc( dbms_random.normal() * 10000 ) DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 40

Rebuild DOAG Konferenz 17.01.2011, Nürnberg Martin Hoermann info@ordix.de www.ordix.de DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 41

Entwicklung Leaf Blocks Rebuild 45.000 40.000 35.000 30.000 25.000 20.000 Mit Rebuild Ohne Rebuild 15.000 10.000 5.000 0 Insert 10.000.000 Rebuild Insert 100.000 Insert 900.000 Insert 4.000.000 DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 42

Index Normalverteilung: Fazit 27 % weniger Leaf Blöcke durch Rebuild 12 % weniger Leaf Blöcke nach 10 % Inserts Kosten pro Insert steigen durch Rebuild Aber ich arbeite nach einem festen Prinzip, wenn mich einer bezahlt, dann führe ich den Auftrag auch aus. (Zwei glorreiche Halunken) DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 43

Agenda Index-Strukturen Testszenarien Nur Inserts Insert + Delete B-Level Optimierung Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 44

Test Insert + Delete 1. Durchlauf 2. Durchlauf 1 Million Sätze Rebuild Delta Ermittlung für 100.000 Delete Block Splits 100.000 Delete Anzahl Leaf Blocks 100.000 Insert Redo Volumen CPU-Zeit 100.000 Delete Consistent Gets 10 x 10 x DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 45

Leaf Nodes 3500 3000 2500 2000 1500 Mit Rebuild Ohne Rebuild 1000 500 0 DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 46

Kumulierte Consistent Gets 600000 500000 400000 300000 200000 Mit Rebuild Ohne Rebuild 100000 0 DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 47

Agenda Index-Strukturen Testszenarien Nur Inserts Insert + Delete B-Level Optimierung Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 48

B-Level Optimierung Überlegung: Kosten Index Unique Scan + Table Access B-Level 3: 4 Consistent Gets B-Level 2: 3 Consistent Gets Performance Optimierung von 25% möglich Einfluss auf das Caching positiv? DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 49

B-Level Optimierung Vergleich nur Insert Nur eine Spalte (Number) Tabelle hat einen Wert 2, sonst nur Einsen PCT_USED ~ 50% PCT_USED ~ 90% durch regelmäßigen Rebuild DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 50

Rebuild DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 51

B-Level Optimierung Height 5 4 3 2 1 Rows PCT_USED = 50 % PCT_USED = 90 % Bereich in Anzahl Rows bei der ein Rebuild die Höhe reduziert DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 52

B-Level Optimierung Height 150.000 bis 250.000 50.000.000 bis 70.000.000 18.500.000.000 Bis? 5 4 3 2 1 Rows PCT_USED = 50 % PCT_USED = 90 % Bereich in Anzahl Rows bei der ein Rebuild die Höhe reduziert DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 53

B-Level Optimierung Caching Effekt durch Branch-Blöcke vernachlässigbar: 10.000 Leaf Blöcke: 67-390 Branch Blöcke 100.000 Leaf Blöcke: 390-700 Branch Blöcke Optimierung nur in sehr speziellen Fällen denkbar DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 54

Agenda Index-Strukturen Testszenarien Fazit DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 55

Referenz I http://richardfoote.wordpress.com/ DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 56

Referenzen II DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 57

Referenzen III DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 58

Formel für Rebuild Jetzt kommt die ultimative Formel für den Rebuild von Indizes! DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 59

Formel für Rebuild DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 60

Formel für Rebuild IF ( cost < benefit ) THEN Rebuild Index END; DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 61

Kosten & Nutzen Distinct Keys Index Scan Clustering Factor PCT_FREE Delete Index Entries Concurrency Multicolumn Caching Compress Bitmap CPU Reverse Storage Validate Structure B-Level Deleted Leafs Organisation Block Splits Statistiken Leaf Blocks Primary Key Redo DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 62

Es gibt zwei Arten von Menschen. Die einen haben einen geladenen Revolver und die anderen Buddeln! Zwei glorreiche Halunken DOAG Konferenz, Index Rebuild - the good, the bad and the ugly, 17.11.2011 63

Zentrale Paderborn Westernmauer 12-16 33098 Paderborn Tel.: 05251 1063-0 Seminarzentrum Wiesbaden Kreuzberger Ring 13 65205 Wiesbaden Tel.: 0611 77840-00 Zentrales Fax: 0180 1 67349 0 0180 1 ORDIX 0 Weitere Geschäftsstellen in Köln, Münster und Neu-Ulm E-Mail: info@ordix.de Internet: http://www.ordix.de