Informationsintegration Dynamische Programmierung

Slides:



Advertisements
Ähnliche Präsentationen
Der R-Baum Richard Göbel.
Advertisements

Algorithmentheorie 08 – Dynamische Programmierung (1)
Kapitel 8 Anfragebearbeitung
Knapsack & Bin Packing Sebastian Stober
Hash-Tabellen und -Funktionen Hash-Tabellen in Java
Informationsintegration Local-as-View: LaV
Informationsintegration Der Bucket-Algorithmus Felix Naumann.
Informationsintegration Verteilte Anfragebearbeitung
Informationsintegration Top-N Anfragen
Informationsintegration Global-as-View: GaV
Informationsintegration Containment und Local-as-View Anfragebearbeitung Felix Naumann.
Informationsintegration Schema Matching Felix Naumann.
Einjährige Berufsfachschule Technik der Fachrichtung Elektrotechnik
Kapitel 8 Anfragebearbeitung
The Dynamic Single File Allocation Problem
Anfrage-Optimierung und -Bearbeitung in Verteilten DBMS
Lehrstuhl Informatik III, DatenbanksystemeMartin Wimmer Übung zu Architektur und Implementierung von Datenbanksystemen 1 Implementierungen des Join- Operators.
Suchbäume Richard Göbel.
Sortierverfahren Richard Göbel.
Sortierverfahren Richard Göbel.
Der R-Baum Richard Göbel.
Traumazentrierte Psychotherapie der chronifizierten, komplexen PTBS vom Phänotyp der Borderline-Persönlichkeitsstörung (Luise Reddemann, Ulrich Sachsse)
Heuristiken Automatic Problem Solving Institut für Informatik
Algorithmentheorie 6 – Greedy-Verfahren
Prof.Dr.S. Albers Prof. Dr. Th. Ottmann
Dynamische Programmierung (2) Matrixkettenprodukt
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (04 – Entwurfsverfahren) Prof. Th. Ottmann.
WS Algorithmentheorie 08 – Dynamische Programmierung (2) Matrixkettenprodukt Prof. Dr. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (27 – Kürzeste Wege) Prof. Th. Ottmann.
WS Algorithmentheorie 08 – Dynamische Programmierung (3) Konstruktion optimaler Suchbäume Prof. Dr. Th. Ottmann.
Informatik II, SS 2008 Algorithmen und Datenstrukturen Vorlesung 4 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Algorithmen und Datenstrukturen
Übung Datenbanksysteme SQL-Anfragen (2)
Seminar: Verteilte Datenbanken
Informationsintegration Architekturen
Informationsintegration Anwendungsszenarien
Informationsintegration Materialisierte vs. Virtuelle Integration
Beispielrelation Buchbestellungen H = Menge der bedeutenden Ziele = {a, d} Schwelle T = 4 Stichprobe S = {a, b, a, a, a, a} mit s = |S| = 6 N = Anzahl.
Intelligentes Crawling im WWW mit Hilfe intuitiver Suchbedingungen
SQL in Visual FoxPro. © 1999 TMN-Systemberatung GmbH SQL Historie n SQL - Structured Query Language n In den 70er Jahren von IBM entwickelt n 1986 zum.
SQL - Ausführungspläne Matthias Jauernig (03INB), Michael Lahl (03IND)
Interoperable Informationssysteme - 1 Klemens Böhm Systeme 2: Query Processing - Grundlagen.
03/02/061 Methoden und Erfahrungen beim Zeichnen von genauen OL-Karten Orest Kotylo.
EXPLAIN PLAN - Erste Schritte April 2004EXPLAIN PLAN2 Was fehlt noch? Konkretes Beispiel für einen Plan.
Dynamische Programmierung mit Anwendung auf Sequence Alignment Problem
WS 2011/12 Datenbanksysteme Fr 15:15 – 16:45 R Vorlesung #8 Anfragebearbeitung.
WS 2012/13 Datenbanksysteme Fr 15:15 – 16:45 R Vorlesung #9 Anfragebearbeitung.
WS 2007/08 Datenbanksysteme Mi 17:00 – 18:30 R Vorlesung #9 Anfragebearbeitung (Teil 1)
Datenbanksysteme für hörer anderer Fachrichtungen
1 Gruppierung, Aggregierung und Sortierung (2) Abarbeitungsmodell bei Gruppierung: Werte from- und where-Klauseln aus wie bisher (Bildung von Kreuzprodukt.
Das relationale Modell
WS 2013/14 Datenbanksysteme Do 17:00 – 18:30 R Vorlesung #9 Anfragebearbeitung.
Das Traveling Salesman Problem (TSP)
Eike Schallehn, Martin Endig
WS 2004/2005 Datenbanken II - 5W Mi 17:00 – 18:30 G 3.18 Vorlesung #3 Anfragebearbeitung (Teil 1)
Query Optimizer in DB2 Leo & POP Learning Optimizer / Progressive Query Optimization.
Einführung Dateisystem <-> Datenbanksystem
Vorlesung Datenbanksysteme vom Anfragebearbeitung  Logische Optimierung.
Der A*-Algorithmus.
Vorlesung Datenbanksysteme vom : Wiederholung Anfragebearbeitung  Logische Optimierung.
WS03/041 Dynamische Programmierung (3) Konstruktion optimaler Suchbäume Prof. Dr. S. Albers Prof. Dr. Th. Ottmann.
12. November 2001 Seminar Geoinformation Folie 1 Inhalt Einführung Bearbeitung raumbezogener Anfragen Ausblick Seminar Geoinformation Themenblock: „Implementierung.
Distributed Database Systems Parallele Datenbanksysteme von Stefan Schneider.
Vorlesung Datenbanksysteme vom Anfragebearbeitung 2  Architektur eines DBMS  Logische Optimierung  Physische Optimierung  Kostenmodelle.
Bachelorarbeit – Andreas Hoffmann Lehrstuhl für Künstliche Intelligenz Prof. Dr. Dr. h.c. mult. W. Wahlster Betreuer: Gerrit Kahl.
Datenbanken Prof. Dr. Ralf Möller Universität zu Lübeck Institut für Informationssysteme Karsten Martiny (Übungen)
Institut für Informationssysteme
Institut für Informationssysteme
Indexierung Oracle: indexes Indexierung.
Abfragestrategien in verteilten Systemen
 Präsentation transkript:

Informationsintegration Dynamische Programmierung 8.12.2005 Felix Naumann

Felix Naumann, VL Informationsintegration, WS 05/06 Überblick Dynamische Programmierung (DP) zur Anfrageoptimierung Grundlagen der DP Das Grundproblem der Anfrageoptimierung DP für Anfrageoptimierung DP für verteilte DBMS 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Richard Bellman 1920 – 1984 PhD Princeton (3 Monate) Los Alamos (1944-1946) 1953 Rand Corporation: Erfindung der Dynamischen Programmierung Viele andere Beiträge zur Mathematik Bellman-Ford Algorithmus 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 The Stagecoach story some 150 years ago there was a salesman travelling west by stagecoach .. A J I H G D F C E B ..at the time there was a serious danger of attack by marauders.. Although his starting point and destination were fixed he had considerable choice as to which states or territories that subsequently became states) to travel through en route. How to determine safest route? Life insurance policies were offered to stagecoach passengers, based on careful evaluation of the safety of the run. The safest route must be that with cheapest total life insurance policy. New York San Francisco Quelle: Folien Ioana Popescu http://faculty.insead.edu/popescu/ioana/ 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Versicherungskosten A J I H G D F C E B 2 4 3 7 6 1 5 Frage: Welches ist der beste (billigste) Weg? Quelle: Folien Ioana Popescu http://faculty.insead.edu/popescu/ioana/ 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Billigster Weg – Greedy Suche 7 1 B E 2 4 4 6 H 3 3 6 4 2 A C F J 4 3 4 4 I 3 3 1 D G 3 5 Greedy: A-B-F-I-J = 13 Frage: Gibt es einen besseren Weg? Quelle: Folien Ioana Popescu http://faculty.insead.edu/popescu/ioana/ 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Billigster Weg – Vollständige Suche 7 1 B E 2 4 4 6 H 3 3 6 4 2 A C F J 4 3 4 4 I 3 3 1 D G 3 5 Anzahl der möglichen Wege: 3 x 3 x 2 = 18 Besser: A-D-F-I-J = 11 Quelle: Folien Ioana Popescu http://faculty.insead.edu/popescu/ioana/ 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

The Stagecoach Solution Idee der Dynamischen Programmierung Hier: “Rückwärtsberechnung” Voraussetzung: Prinzip der Optimalität Teilplan eines optimalen Plans ist ebenfalls optimal Idee Ausgehend vom Zielknoten stufenweise rückwärts beste Teilpfade berechnen F(X) := minimale Kosten von X nach J Dijkstra’s Algorithm Also A-D-E-H-J =11 And A-C-E-H-J=11 Quelle: Folien Ioana Popescu http://faculty.insead.edu/popescu/ioana/ 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Billigster Weg - DP A J I H G D F C E B 2 4 3 7 6 1 5 F(E)=4 F(B)=11 F(H)=3 F(A)=11 F(J)=0 F(F)=7 F(C)=7 F(I)=4 F(G)=6 F(D)=8 F(X) : = min Kosten von X nach J Quelle: Folien Ioana Popescu http://faculty.insead.edu/popescu/ioana/ 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Dynamische Programmierung Optimaler Algorithmus „Schwierigkeiten“ Prinzip der Optimalität muss gelten. Aufteilung des Problems in Teilprobleme Aufwand kann exponentiell sein Klassische Anwendungen Knapsack Problem Traveling Salesman Problem Maschinenbelegung Transportproblem 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Überblick Dynamische Programmierung (DP) zur Anfrageoptimierung Grundlagen der DP Das Grundproblem der Anfrageoptimierung DP für Anfrageoptimierung DP für verteilte DBMS 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Architektur zur Anfragebearbeitung Logische Optimierung (unabhängig von System und Konfiguration): Entschachtelung, redundante Prädikate,... Wandelt Plan (Baum) in ausführbaren Plan (Code) um. Anfrage- ergebnis Anfrage Parser Anfrage- umschreibung Anfrage- optimierung Code Generierung Anfragebearbeitung (Engine) Katalog/ Metadaten Optimierung für System und Konfiguration: Indices, Joinreihenfolge, Selektion der Datenquelle Daten Syntax und etwas Semantik Erzeugt Anfragegraph Schema, Statistik, Partitionierung, Lage der Daten,... 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Anfrageoptimierung Suchraum Alle gültigen Anfragepläne Kostenmodell Join-Operator Netzwerkkosten Optimierungsproblem Finde im Suchraum den kostenoptimalen Anfrageplan. 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Anfrageplanung Heuristische Einschränkung des Suchraums Keine Kreuzprodukte Außer explizite Kreuzprodukte in der Anfrage Prädikate so früh wie möglich Nur links-tiefe (left-deep) Bäume ⋈ ⋈ Left-Deep Bushy Zig-Zag Pipelined Execution ⋈ ⋈ ⋈ ⋈ ⋈ ⋈ ⋈ R S T U T R S U R S T U 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Überblick Dynamische Programmierung (DP) zur Anfrageoptimierung Grundlagen der DP Das Grundproblem der Anfrageoptimierung DP für Anfrageoptimierung DP für verteilte DBMS 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Dynamische Programmierung: Optimierung im System-R A.k.a. “Selinger-style query optimization” Der klassische Artikel zur Anfrageoptimierung: [SAC+79] Ursprünglich im IBM System-R Heutzutage weit verbreitet Grundidee: Nur “Left-deep” Anfragebäume D.h. nur Joinreihenfolge interessant Innere und äußere Relation unberücksichtigt Bottom-up Generierung von Anfrageplänen Dynamische Programmierung (DP) Zusätzlich: interesting orders (interessante Sortierungen) Zusätzlich: interesting sites (interessante Ausführungsorte) Literatur mit Beispiel: [GMUW00] Quelle: u.a. Folien Prof. Chen Li 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Bottom-up Anfrageplangenerierung Grundannahme 1: Nach dem Join über k Relationen ist die Join-Methode die k+1te Relation um hinzuzujoinen unabhängig von den vorigen Join-Methoden. Joinmethoden: Nested Loops, Hashjoin, Sort-Merge Join usw. Grundannahme 2: Jeder Teilplan eines optimalen Plans ist ebenfalls optimal. Entspricht dem Prinzip der Optimalität: Wenn sich zwei Pläne nur in einem Teilplan unterscheiden, so ist der Plan mit dem besseren Teilplan auch der bessere Gesamtplan Bottom-up Anfrageplangenerierung: Berechne die optimalen Pläne für den Join über (jede Kombination von) k Relationen Suboptimale Pläne werden verworfen Erweitere diese Pläne zu optimalen Plänen für k+1 Relationen. usw. bis k = n 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Dynamische Programmierung {} {R} {S} {T} {U} {R S} {R T} {R U} {S T} {S U} {T U} {R S T} {R S U} {S T U} {R T U} {R S T U} 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP – Grundidee für Anfrageoptimierung Für jede Kombination merke (in einer Hilfstabelle): Geschätzte Größe des Ergebnisses (Kardinalität) Geschätzte minimale Kosten Hier zur Vereinfachung: Größe des Zwischenergebnisses Joinreihenfolge, die diese Kosten verursacht (= optimaler Teilplan) Induktion über Anzahl der Relationen im Plan N=1: Für jede Relation Kardinalität = Kardinalität der Relation Kosten = 0 (zur Vereinfachung) Joinreihenfolge: n/a N=2: Für jedes Relationenpaar R, S Kardinalität = |R| x |S| x sf Kosten = 0 Joinreihenfolge: kleinere Relation links Clou: R und S jeweils mit besten access-path N=3: Für jedes Tripel R, S, T Clou: Nur bestes Relationenpaar aus dem Tripel wird um dritte Relation ergänzt ... 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 DP – Beispiel S T Anfrage über Relationen R, S, T, U. Vier Join-Bedingungen Anfragegraph R U u.U. auch IndexScan(...) 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

X X DP – Beispiel S T R U Kreuzprodukte nicht berücksichtigen! Besser als z.B. S ⋈ (T ⋈ R) oder (R ⋈ S) ⋈ T 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP – Beispiel Bisher unberücksichtigt: Wahl des Join-Algorithmus S T R Anfragegraph R U Bisher unberücksichtigt: Wahl des Join-Algorithmus Optimaler (left-deep) Plan 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP - interesting orders (Interessante Sortierung) WdH.: Prinzip der Optimalität: Wenn sich zwei Pläne nur in einem Teilplan unterscheiden, so ist der Plan mit dem besseren Teilplan auch der bessere Gesamtplan. Gegenbeispiel: R(A,B) ⋈ S(A,C) ⋈ T(A,D) Bester (lokaler) Plan für R ⋈ S: Hash-Join Best (globaler) Gesamtplan: 1. Sort-merge Join über R und S 2. Sort-merge Join mit T Warum könnte dies so sein? Das Zwischenergebnis von R ⋈sort-mergeS ist nach Join-Attribut A sortiert. Dies ist eine interesting order, die später ausgenutzt werden kann: Spätere sort-merge Joins Gruppierung (GROUP BY) Sortierung (ORDER BY) Eindeutige Tupel (DISTINCT) 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP - interesting orders (Interessante Sortierung) Bei Auswahl des besten Teilplans: Kostenvergleich genügt nicht. Es gibt keine vollständige Ordnung der Teilpläne nach Kosten. Auch Sortierungen müssen berücksichtigt werden. Lösung: Für jede Kombination von Relationen, speichere mehrere Sortiervarianten: Nach jeder Variante der beteiligten Teilpläne Die “leere” Sortierung DP Tabellen werden „breiter“. Merke außerdem Join- und Sortieroperationen, die diese Sortierung erzeugen. 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP – Algorithmus Alle Zugriffspläne für jede Relation Schlechtere Zugriffs-pläne verwerfen Achtung: Nicht left-deep! Quelle: [Ko00] 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Überblick Dynamische Programmierung (DP) zur Anfrageoptimierung Grundlagen der DP Das Grundproblem der Anfrageoptimierung DP für Anfrageoptimierung DP für verteilte DBMS 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP in verteilten Systemen Entscheidungen des Optimierers Zugriffpfade auf Relationen Table-scan, Index-scan Joinreihenfolge Art der Join-Berechnung Nested loops, sort-merge usw. Neu: Ort der Join-Berechnung Am Speicherort der inneren Relation / des Zwischenergebnisses Am Speicherort der äußere Relation / des Zwischenergebnisses Am Ort der Weiterverarbeitung Anderswo, z.B. Ort der schnellsten CPU 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

DP in verteilten Systemen Berücksichtigung (und Repräsentation) mehrerer Speicherorte ⇒ mehr Zugrifspläne Berücksichtigung (und Repräsentation) des Ausführungsortes des Joins ⇒ interesting order und interesting site ⇒ mehr Zugrifspläne Am Ende gegebenenfalls noch ship Operator anfügen. 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06

Felix Naumann, VL Informationsintegration, WS 05/06 Literatur Das grundlegende Paper [SAC+79] Patricia G. Selinger, Morton M. Astrahan, Donald D. Chamberlin, Raymond A. Lorie, Thomas G. Price: Access Path Selection in a Relational Database Management System. SIGMOD Conference 1979: 23-34 Englisches Lehrbuch [GMUW00] Hector Garcia-Molina, Jeffrey D. Ullman, Jennifer Widom: Database System Implementation Prentice-Hall 2000 Weiteres [Ko00] The State of the Art in Distributed Query Processing, Donald Kossmann, ACM Computing Surveys 32(4), pages 422-469. (Link auf WWW) [OK00] Kiyoshi Ono, Guy M. Lohman: Measuring the Complexity of Join Enumeration in Query Optimization. VLDB 1990: 314-325 [HFLP89] Laura M. Haas, Johann Christoph Freytag, Guy M. Lohman, Hamid Pirahesh: Extensible Query Processing in Starburst. SIGMOD Conference 1989: 377-388 [Graefe93] Goetz Graefe: Query Evaluation Techniques for Large Databases. ACM Comput. Surv. 25(2): 73-170 (1993) 8.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06