informationsintegration verteilte anfragebearbeitung 1.12.2005 felix naumann

61
Informationsintegrati on Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

Upload: cundrie-karchner

Post on 05-Apr-2015

109 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

InformationsintegrationVerteilte

Anfragebearbeitung

1.12.2005

Felix Naumann

Page 2: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 2

ProblemstellungArchitekturenModellierungOptimierung

10,000 feet

1. Einführung in die Informationsintegration2. Szenarien der Informationsintegration3. Verteilung und Autonomie4. Heterogenität5. Materialisierte und virtuelle Integration6. Klassifikation integrierter Informationssysteme und 5-Schichten

Architektur 7. Mediator/Wrapper-Architektur8. Global-as-View und Lokal-as-View Modellierung9. Global-as-View Anfragebearbeitung 10. SchemaSQL11. Verteilte Anfragebearbeitung12. Dynamische Programmierung in verteilten Datenbanken13. Top-N Anfragen

Page 3: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 3

KonflikteAnfragen

SystemeMapping

10,000 feet

1. Informationsqualität2. Duplikaterkennung3. ETL & Data Lineage 4. Datenfusion - Union & Co.5. Containment & Local-as-View Anfragebearbeitung6. Bucket Algorithmus 7. Peer-Data-Management Systeme (PDMS) 8. Schema Mapping9. Schema Matching 10. Hidden Web11. Semantic Web12. Forschungsprojekte  - TSIMMIS, Garlic, Revere, etc13. Data Streams

Page 4: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 4

Überblick

Anfragebearbeitung im Überblick Techniken der Verteilten

Anfragebearbeitung Row Blocking Multicasts Multithreading Partitionierung

Joinbearbeitung Semi-Join Reduzierung Semi-Join mit Filter

Page 5: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 5

Parallelität vs. Verteilung

Parallele DBMS Shared memory Shared disk Shared nothing Fokus auf Transaktionen und Anfragebearbeitung

Verteilte DBMS Shared nothing Fokus auf Heterogenität und Anfragebearbeitung Unser Fokus!

Page 6: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 6

Architektur zur zentralen Anfragebearbeitung

ParserAnfrage-

umschreibungAnfrage-

optimierungCode

GenerierungAnfragebearbeitung

(Engine)

Katalog/Metadaten

Anfrage

Daten

Anfrage-ergebnis

Syntax und etwas SemantikErzeugt Anfragegraph

Logische Optimierung (unabhängig von System und Konfiguration):Entschachtelung, redundante Prädikate,...

Optimierung für System und Konfiguration:Indices, Joinreihenfolge, Selektion der Datenquelle

Wandelt Plan (Baum) in ausführbaren Plan (Code) um.

Schema, Statistik, Partitionierung, Lage der Daten,...

Page 7: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 7

Anfragebearbeitung in verteilten Systemen

Anfragen sind deklarativ. Anfragen müssen in

ausführbare (prozedurale) Form transformiert werden.

Ziele QEP – prozeduraler Query

Execution Plan Effizienz

Schnell Wenig Ressourcenverbrauch

(CPU, I/O, RAM, Bandbreite)

Page 8: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 8

Schritt 1: Anfragetransformation

1. Parsen der Anfrage (Syntax)2. Namensauflösung3. Überprüfen der Elemente

(Semantik)4. Normalisierung

– Konjunktive Normalform in WHERE Klausel

5. Algebraische Vereinfachung– Eliminierung redundanter

Teilausdrücke

6. Transformation zum Operatorbaum

Page 9: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 9

Schritt 2: Daten-Lokalisierung

Globale Relationen werden abgebildet auf lokale Relationen GaV / LaV

Algebraische Vereinfachungen

Page 10: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 10

Schritt 3: Globale Optimierung Bestimmung eines Ausführungsplanes mit minimalen globalen

Kosten Bestimmung der Ausführungsknoten Festlegung der Ausführungsreihenfolge (sequentiell, parallel) Alternative Strategien zur Join-Berechnung bewerten (z.B. mit

Semi-Join) Aber: Trennung zwischen globaler und lokaler Optimierung kann zur

Auswahl suboptimaler Pläne führen Kostenmodell

|Instruktionen| + |Diskzugriffe| + |Nachrichten| + |übertragene Byte|

Kosten = (TCPU * #insts) + (TI/O * #I/Os) + (TMSG * #msgs) + (TTR * #byte)

Page 11: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 11

Site 0

Site 1

Neue Ziele der Anfragebearbeitung In zentralisierten (mehr-

Benutzer) DBMS Durchsatz (throughput) =

Anzahl der verarbeiteten Tupel

Minimierung des Ressourcenverbrauchs

In verteilten DBMS Gesamt-

Ressourcenverbrauch erhöhen um schnellere Antworten zu erhalten

Minimierung der Antwortzeit

R S

T U

R S

sendSite 2

T U

send

Site 0⋈

receive receive

Page 12: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 12

Dimensionen der Anfragebearbeitung Festlegung des Ausführungsknotens Festlegung der Auswertungsstrategie

Ship whole Vollständige Relationen Wenig Nachrichten Viele Byte

Fetch rows as needed Bindings Viele Nachrichten Nur relevante Byte Semi Join

Fetch columns as needed Semi-Join

Site 1

R S

sendSite 2

T U

send

Site 0⋈

receive receive

Page 13: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 13

Schritt 4: Lokale Optimierung

Entsprechend des jeweiligen Systems Lokale Katalogdaten Lokale Parameter

TCPU und TI/O

Etc.

Page 14: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 14

Überblick

Anfragebearbeitung im Überblick Techniken der Verteilten

Anfragebearbeitung Row Blocking Multicasts Multithreading Partitionierung

Joinbearbeitung Semi-Join Reduzierung Semi-Join mit Filter

Page 15: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 15

Row Blocking

Anfragebearbeitung in verteilten DBMS mittels send und receive Operatoren

Naiv: Für jedes Tupel eine send und eine receive Operation

Besser: Row blocking Tupel werden gesammelt und en block versendet. Blockgröße abhängig von datagram-Größe im

Netzwerk (z.B. 64kB) Queues puffern unregelmäßige Pipelines

Wichtig in Netzwerken; Stillstand wird vermieden.

Page 16: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 16

Row Blocking

Site 1

R S

sendSite 2

T U

send

Site 0

receive receive

Puffer Puffer

PufferPuffer

Netzwerkun-regelmäßigkeite

n

Row blocking

Erlaubt konstante(re) Ausführung des restlichen Plans

Page 17: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 17

Multicasts

Site 1

R

send

Site 2

S

send

Site 0

receive receive

receive

Site 1

R

send

Site 2

S

send

Site 0

receive receive

receive

sendOptimierung

T

T

Page 18: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 18

Multicasts Einsparungen

Netzverkehr CPU (packing und unpacking)

Optimierung Viele Alternativen

Physisch: Welche Daten schicke ich wohin? Welchen Operator führe ich wo aus?

Logisch: Outer joins statt inner joins Späte/Frühe Projektion Usw.

Kostenmodell Dynamische Entscheidungen

noch während der Ausführung!

Site 1

R

send

Site 2

S

send

Site 0

receive receive

receive

send

T

Page 19: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 19

Multi-Threading Single-threaded UNION:

Sukzessive ein Datagram von einer Site

„Round-robin“-Verfahren Multi-threaded UNION:

Parallele Verarbeitung der send und receive Operationen

Vorteile Netzwerkverkehr parallel Send Operationen parallel

Nachteile Zusätzliche Kosten durch

Synchronisation (shared memory) Zusätzliche Kosten durch

Konkurrenz um Ressourcen Optimierer muss entscheiden

welche Operatoren in wie vielen Threads ausgeführt wird.

Site 0∪

receive receive

Site 1

R

send

Site 2

R

send

Site 3

R

send

receive

Page 20: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 20

Multi-Threading

Multi-threading nicht immer vorteilhaft z.B. Speicherplatz Site 0

Sort-merge-join

receive

Site 1

R

send

Site 3

S

send

receive

sort sort

Page 21: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 21

Partitionierung Grundlagen von DBMS Vertikal

Verschiedene Projektionen einer Relation Jedes Attribut in mindestens einer Partition Erhalt eines Schlüssels! Auch: Normalisierung

Horizontal Verschiedene (disjunkte) Selektionen einer Relation Beispiel

Partition A: SELECT * FROM R WHERE area=`Nord´ Partition B: SELECT * FROM R WHERE area=`Süd´ (bzw. `Nord´)

Jedes Tupel in mindestens einer Partition Optimierung

Wie partitionieren? Wie die Partitionen verteilen? Abhängig von Anwendungen und query workload

Page 22: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 22

Joins über horizontale Partitionen

Sei R horizontal partitioniert R = R1 ∪ R2

Alternativen R ⋈ S = (R1 ∪ R2) ⋈ S

R ⋈ S = (R1 ⋈ S) ∪ (R2⋈ S)

Komplikationen R noch weiter partitioniert S ebenfalls partitioniert Unterschiedliche Kosten Wer führt was wo aus?

Page 23: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 23

Selektion über horizontale Partitionierung

Beispiel: Mitschang, VL „Verteilte DBMS“

Page 24: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 24

Join über horizontale Partitionierung

Beispiel: Mitschang, VL „Verteilte DBMS“

Page 25: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 25

Joins über horizontale Partitionen

Site 1

R1 S

send

Site 2

R3 S

send

Site 0∪

receive receive

R2

Site 1

R1 S

send

Site 2

R3 S

send

Site 0

⋈receive receive

R2

sendreceive

Optimierung|R|

|S|

|R3|

|(R1 R⋃ 2) S⋈ ||R3 S⋈ |

Frage: Wieviel wird jeweils übertragen?

Page 26: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 26

Joins über horizontale Partitionen Optimierung

Lage der Partitionen Kostenvergleiche Leere Teilergebnisse (Ri ⋈ Sj = )

Vorhersagen & Vermeiden Häufig: Zwei Relationen nach gleichem Prädikat

partitioniert „Abteilungen“ nach Standort partitioniert (Nord, Süd) „Mitarbeiter“ nach Abteilung (also auch nach Standort)

partitioniert Dann: R ⋈ S

= (R1⋈S1) (∪ R1⋈S2) (∪ R2⋈S1) (∪ R2⋈S2)= (R1⋈S1) (∪ R2⋈S2)

D. h. Joins (Ri ⋈ Sj) nur ausführen falls i = j

Page 27: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 27

Überblick

Anfragebearbeitung im Überblick Techniken der Verteilten

Anfragebearbeitung Row Blocking Multicasts Multithreading Partitionierung

Joinbearbeitung Semi-Join Reduzierung Semi-Join mit Filter

Page 28: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 28

Semi-Join

Site 0

S

send

Site 1⋈

receive R

|S| x tuple-length(S)

Ergebnis (ohne Attribute von S) in Site 1 verlangt

Site 0

S

send

Site 1⋈

receive R

|S| x ID-length(S)

ID

Page 29: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 29

Semi-Join

Site 0

S

send

Site 1⋈

receive R

Site 1

R

send

Site 0

receive S

send

ID

receive

|S| x tuple-length(S)

|R| x ID-length(R)

|R ⋈ S| x tuple-length (S)

Merge-join

Ergebnis (mit Attributen von S) in Site 1 verlangt

Page 30: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 30

Semi-Join

Formal R(A), S(B) R ⋉ S := A(R⋈FS)

= A(R) ⋈F AB(S)= R⋈F AB(S)i.d.R. = R⋈F F(S)

Nicht symmetrisch! Literatur:

[BC81] in jedem DB Lehrbuch

Page 31: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 31

Semi-Join

Site 0

S

send

Site 1⋈

receive

Site 0

S

send

Site 2

receive R

send

ID

receive

|S| x tl(S)

|S| x ID-length(S)

|R ⋈ S| x ID-length (R)

Site 2

R

send

receive

|R| x tl(R)

Site 1⋈

receive receive

ID

send

send

Ergebnis (Attribute aus S und R) in Site 1 verlangt

Frage: Welche 2 anderen Strategien sind möglich?

|R ⋈ S| x tl(S)

|R ⋈ S| x tl(R)

Frage: Welche anderen Strategien sind möglich?

Page 32: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 32

Optimierung mit Semi-Join

Transformationsregeln für Joins R⋈FS =

(R ⋉F S) ⋈F S R verkleinern, dann Join mit S

R⋈F (S ⋉F R) S verkleinern, dann Join mit R

(R ⋉F S) ⋈F (S ⋉F R) R und S verkleinern dann Join.

Problem: Wann welche Variante einsetzen?

Frage: Welche beiden Varianten standen auf der vorigen Folie?

Page 33: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 33

Optimierung mit Semi-Join

Kostenmodell |Instruktionen| + |Diskzugriffe| + |Nachrichten| + |übertragene

Byte| Kosten = TCPU * #insts

+ TI/O * #I/Os + TMSG * #msgs + TTR * #byte

Hier nur: |übertragene Byte|

Kostenvergleich (Annahme: |R| < |S|) K(R⋈FS) = byte(R)

K((R ⋉F S) ⋈F S) = byte(F(S)) + byte((R ⋈F S))

Page 34: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 34

Eine Übung im letzten Jahr:Die Daten Zwei Datenbanken in DB2

FilmDB1 Schema: Movie1 Tabelle: Movie1.Filme1(Titel Character(100), Jahr Integer)

FilmDB2 Schema: Movie2 Tabelle: Movie2.Filme2(Titel Character(100), Regie

Character(50)) Zugriffsberechtigungen:

Lesend auf die Tabellen CREATE TABLE auf die Datenbanken INSERT auf neue Tabellen

Page 35: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 35

Eine Übung im letzten Jahr:Die Aufgabe

Titel und Regisseur aller Filme, die jünger als 1980 sind.

SELECT F1.Titel, F2.RegieFROM Movie1.Filme1 F1, Movie2.Filme2 F2WHERE F1.Titel = F2.TitelAND F1.Jahr > 1980

Zur Kontrolle: Ergebniskardinalität ist 1121. Problem: Join über verschiedene Datenbanken

Passing Binding Semijoins Andere?

Page 36: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 36

Eine Übung im letzten Jahr:Auswertung

0

2000000

4000000

6000000

8000000

10000000

12000000

14000000

16000000

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Noch naiver: Große Tabelle außen.

Gruppe

Byt

e

Naive Lösung (vorgegeben):Kosten = 8.296.344 Byte

Page 37: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 37

Eine Übung im letzten Jahr:Die gesammelten Tricks Prepared Statement Rtrim() Filme2 ist wesentlich kleiner Gezielte Projektionen

Jahr muss nie übertragen werden Jeder Titel höchstens einmal

Hashfunktionen als UDF In SPJ Anfrage Auf Kollisionen getestet Optimiert auf Länge

Rollback statt drop table

Page 38: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 38

Chipmunks CREATE TABLE firma06 (h INTEGER NOT NULL PRIMARY KEY) alle "hash" Werte für titel aus Firma2 holen

SELECT DISTINCT ASCII(titel)*762534+LENGTH(RTRIM(titel))*464857+(ASCII(substr(rtrim(titel),length(rtrim(titel)))))*659386+(ASCII(SUBSTR(RTRIM(titel),(LENGTH(RTRIM(titel))/2)+1,1)))*121555+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.5573769496370024-0.5,0))+1,1)))*481517+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.5455918517007877-0.5,0))+1,1)))*418045+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.9390929989171091-0.5,0))+1,1)))*479165+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.3093312770038853-0.5,0))+1,1)))*151240+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.13964794618711818-0.5,0))+1,1)))*668683+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.7438338851875961-0.5,0))+1,1)))*208042+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.24890649793926223-0.5,0))+1,1)))*386682+(ASCII(SUBSTR(RTRIM(titel),integer(round(length(rtrim(titel))*0.7727779326492414-0.5,0))+1,1)))*49285 FROM movie2.filme2

Page 39: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 39

0

500000

1000000

1500000

2000000

2500000

3000000

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Eine Übung im letzten Jahr:Auswertung

idefix

Ghost D

ogs

camarilla

bib

gruppe1

IFA

blub

10099

Die D

rei

ii Projekt C

haos

0815

Hedge K

nights

Chipm

unks

fmr

Page 40: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 40

Überblick

Anfragebearbeitung im Überblick Techniken der Verteilten

Anfragebearbeitung Row Blocking Multicasts Multithreading Partitionierung

Joinbearbeitung Semi-Join Reduzierung Semi-Join mit Filter

Page 41: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 41

Optimierung mit Semi-Join Komplexeres Beispiel

R ⋈FS ⋈G T = (R ⋉F S) ⋈F (S ⋉G T) ⋈G T = (R ⋉F (S ⋉G T)) ⋈F (S ⋉G T) ⋈G T

Allgemein: Man suche für jede Relation das beste Semi-Join Programm, den vollständigen Reduzierer („full reducer“). Eine fully reduced Relation enthält keine Tupel, die nicht zur

Anfragebearbeitung benötigt werden. Für jede Relation in einer Anfrage existieren exponentiell viele

Semi-Join Programme. Zyklische Anfragen: i.A. existiert kein full reducer. Baum-Anfragen: Finden des full reducer NP-schwer. Ketten-Anfragen: Finden des full reducer polynomial.

Page 42: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 42

Optimierung mit Semi-Join

Ketten-AnfragenSELECT EMP.name, DEPT.nameFROM EMP, DEPT, PROJWHERE EMP.d_ID = DEPT.IDAND EMP.p_ID = PROJ.ID

EMPLOYEESPROJECTS DEPARTMENTS

Mitarbeiter mit ihren Abteilungen, die an

einem Projekt arbeiten.

Ermittlung der full reducer für jede Relation in 2 Phasen1. Vorwärts2. Rückwärts

Page 43: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 43

Fully Reduce Ermittlung der full reducer für jede Relation in 2 Phasen

1. Vorwärts2. Rückwärts

Allgemein für Kettenanfragen R1 ⋈A R2 ⋈B ... ⋈Y R(n-1) ⋈Z Rn Vorwärts

R2‘ = R2 R1⋉ R3‘ = R3 R2‘ = R3 (R2 R1)⋉ ⋉ ⋉ ... Rn‘ = Rn R(n-1)‘ = ...⋉

Rückwärts R(n-1)‘‘ = R(n-1)‘ Rn‘⋉ R(n-2)‘‘ = R(n-2)‘ R(n-1)‘⋉ ... R1‘‘ = R1 R2‘‘⋉

Full reducer für Rn

Full reducer für R(n-1)

Full reducer für R1

Page 44: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 44

Fully Reduce

Beispiel für Kettenanfragen R1 ⋈A R2 ⋈B R3 ⋈C R4 Vorwärts

R2‘ = R2 ⋉ R1 R3‘ = R3 ⋉ R2‘ [= R3 ⋉ (R2 ⋉ R1)] R4‘ = R4 ⋉ R3‘ [= R4 ⋉ (R3 ⋉ (R2 ⋉ R1))]

Rückwärts R3‘‘ = R3‘ ⋉ R4‘ R2‘‘ = R2‘ ⋉ R3‘‘ R1‘‘ = R1 ⋉ R2‘‘

Page 45: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 45

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

A

B C

⋊ ⋊ ⋊

⋉⋉⋉C

BA

Full reducer

VorwärtsR2‘ = R2 R1⋉R3‘ = R3 R2‘⋉R4‘ = R4 R3‘⋉

RückwärtsR3‘‘ = R3‘ R4‘ ⋉R2‘‘ = R2‘ ⋉R3‘‘ R1‘‘ = R1 R2‘‘⋉

Page 46: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 46

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

Page 47: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 47

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

(1,5,6,7)

Page 48: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 48

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

(1,5,6,7) (3,5,7)

Page 49: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 49

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

(1,5,6,7) (3,5,7) (1,2,3)

Page 50: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 50

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

(1,5,6,7) (3,5,7) (1,2,3)

(2,3)

Page 51: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 51

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

(1,5,6,7) (3,5,7) (1,2,3)

(2,3)(5,7)

Page 52: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 52

Fully Reduce – Beispiel

Site 0 Site 1 Site 2 Site 3

R1 R2 R3 R4

X A

1 7

2 1

3 6

4 7

5 5

6 7

A B

9 3

5 5

7 7

5 3

0 7

3 2

B C

3 1

1 0

7 2

7 1

5 3

6 0

C Z

2 1

3 2

4 5

5 6

6 7

7 8

R1 ⋈A R2 ⋈B R3 ⋈C R4

(1,5,6,7) (3,5,7) (1,2,3)

(2,3)(5,7)(5,7)

Page 53: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 53

Fully Reduce

Gegeben Baum-Anfrage Q (R4 ⋈C (R3 ⋈D R5)) ⋈B (R1 ⋈A R2)

R1

R2

R3

R4

R5

R1

R2 R3

R4 R5

⋈ ⋈

⋈ ⋈

Auswahl der Wurzel beliebig

Baumdarstellung rein graphisch!

Page 54: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 54

Fully Reduce

Phase 1 Von unten nach oben Ziel: Full reducer für Wurzel Einführung von Semi-Joins von Knoten

zu ihren Eltern

Phase 2 Von oben nach unten Ziel: Full reducer für alle anderen

Knoten Einführung von Semi-Joins von Knoten

zu ihren Kindern

R1

R2 R3

R4 R5

⋈ ⋈

⋈ ⋈

Page 55: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 55

Fully Reduce – Phase 1

R1

R2 R3

R4 R5

⋈ ⋈

⋈ ⋈R1

R2 R3

R4 R5

⋊⋉

⋈ ⋈R1

R2 R3

R4 R5

⋊⋉

⋊⋉

Erfüllte Bedingungen:- R3.C = R4.C- R3.D = R5.D

Erfüllte Bedingungen:- R3.C = R4.C- R3.D = R5.D- R1.A = R2.A- R1.B = R3.B

Ergebnis in R1 erfüllt alle Beding-ungen, ist also fully reduced.

Page 56: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 56

Optimierung mit Semi-Join

Zyklische Anfragen

DEPT

DName ID

a 1

b 2

SELECT EMP.name, DEPT.nameFROM EMP, DEPT, PROJWHERE EMP.d_ID = DEPT.IDAND EMP.p_ID = PROJ.IDAND PROJ.d_ID = DEPT.ID

EMPLOYEES

PROJECTS

DEPARTMENTS

Mitarbeiter, die an Projekten der

eigenen Abteilung arbeiten

PROJ

d_ID ID PName

1 6 Clio

2 7 HumMer

EMP

EName d_ID p_ID

X 1 7

y 2 6

Problem: Semi-Join betrachtet immer nur eine Kanteim Anfragebaum und blickt nicht voraus.Ergebnis ist nie die leere Menge.

Page 57: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 57

Überblick

Anfragebearbeitung im Überblick

Techniken der Verteilten Anfragebearbeitung Row Blocking Multicasts Multithreading Partitionierung

Joinbearbeitung Semi-Join Reduzierung Semi-Join mit Filter

Page 58: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 58

Optimierung mit Semi-Join

Verbesserung durch Hashfilter Idee: Statt A(R) sende man nur eine „Signatur“

(Bloom-Filter). Weniger Netzwerkverkehr.

Page 59: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 59

Join mit Hashfilter(Bloom-Filter)

111100

111100 False

drops

6 Bit

12 Werte (4 Tupel, inkl. 2 False Drops)

15 Werte

Quelle: VL-Folien, Alfons Kemper, Uni Passau

⋈C

Page 60: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 60

Rückblick

Techniken der verteilten Anfragebearbeitung Row Blocking Multicasts Multithreading Partitionierung

Semi-Join Basics Reduzierung Mit Filter

Site 1

R

send

Site 0

receive S

send

ID

receive

Page 61: Informationsintegration Verteilte Anfragebearbeitung 1.12.2005 Felix Naumann

1.12.2005 Felix Naumann, VL Informationsintegration, WS 05/06 61

Literatur Überblick

Fast jedes deutsche DBMS Lehrbuch Englisch: [GMUW00] Hector Garcia-Molina, Jeffrey D. Ullman,

Jennifer Widom: Database System Implementation Prentice-Hall 2000

Spezielles [Ko00] The State of the Art in Distributed Query Processing,

Donald Kossmann, ACM Computing Surveys 32(4), pages 422-469. (Link auf WWW)

[Graefe93] Goetz Graefe: Query Evaluation Techniques for Large Databases. ACM Comput. Surv. 25(2): 73-170 (1993)

Semijoin [BC81] Philip A. Bernstein, Dah-Ming W. Chiu: Using Semi-Joins

to Solve Relational Queries. Journal of the ACM 28(1): 25-40 (1981)