Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

Informationsintegration Top-N Anfragen

Ähnliche Präsentationen


Präsentation zum Thema: "Informationsintegration Top-N Anfragen"—  Präsentation transkript:

1 Informationsintegration Top-N Anfragen
Felix Naumann

2 Felix Naumann, VL Informationsintegration, WS 05/06
Überblick Anfragen nach den ERSTEN Ergebnissen (First-N) “Es reicht!“ in SQL [CK97] Syntax und Semantik Optimierung Anfragen nach den BESTEN Ergebnissen (Top-N) Motivation Fagin‘s Algorithm Felix Naumann, VL Informationsintegration, WS 05/06

3 Motivation für First-N
1. Anfragen Semantik: Korrektheit Vollständigkeit D.h. alle Ergebnisse erwünscht Bsp.: Aggregation Anwendungen: DBMS Data Warehouses 2. Browsen So korrekt wie möglich So vollständig wie gewünscht D.h. einige, bespielhafte Ergebnisse Bsp: Life Sciences Anwendungen GUI 3. Suchen Semantik So korrekt wie möglich Nur die besten Ergebnisse D.h. Ein oder wenige passende Ergebnisse Bsp: Dokumente Anwendungen: Digital Library Systeme Content Management Systeme Google Felix Naumann, VL Informationsintegration, WS 05/06

4 Informationsintegration und Browsen
Warum sind First-N Techniken für die Informationsintegration interessant? Für Nutzer Art der Daten unbekannt Umfang der Daten unbekannt Browsen Nutzen/Qualität der Daten sowieso zweifelhaft Anfragen nur fuzzy formuliert Verfeinerung der Anfrage in weiteren Schritten Query refinement Für System Datenbeschaffung oft langsam und teuer Deshalb: Großes Optimierungspotential Lokale Optimierung Globale Optimierung: Netzwerkkosten Felix Naumann, VL Informationsintegration, WS 05/06

5 Anfragebearbeitung in DBMS
SQL Anfrage formulieren System nimmt SQL Anfrage entgegen Parsen Optimieren System führt Anfrage aus Tupel-pipeline aufbauen Ergebnistupel in temporäre Tabelle schreiben Rückgabe eines Cursors auf erstes Ergebnistupel Sukzessives next() auf Cursor durch Anwendung GUI (z.B. AquaDataStudio) Programm (z.B. mittels JDBC) Felix Naumann, VL Informationsintegration, WS 05/06

6 Anfragebearbeitung in DBMS
Problem DBMS berechnet vollständiges Ergebnis Anwendung holt eventuell nur wenige Tupel z.B. ein Fenster voll z.B. Top-N Ergebnisse entsprechend einer Sortierung Anwendung spart Aufwand, DBMS jedoch nicht! Felix Naumann, VL Informationsintegration, WS 05/06

7 Felix Naumann, VL Informationsintegration, WS 05/06
Überblick Anfragen nach den ERSTEN Ergebnissen (First-N) “Es reicht!“ in SQL [CK97] Syntax und Semantik Optimierung Anfragen nach den BESTEN Ergebnissen (Top-N) Motivation Fagin‘s Algorithm Felix Naumann, VL Informationsintegration, WS 05/06

8 SQL SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ...
Selektion und Join-Bedingungen Projektion Relationen SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... Gruppierung Sortierung Selektion nach Gruppierung Felix Naumann, VL Informationsintegration, WS 05/06

9 Felix Naumann, VL Informationsintegration, WS 05/06
Teures SQL – Beispiel SELECT h.name, h.adresse, h.tel FROM hotels h, flughäfen f WHERE f.name = ‚TXL‘ ORDER BY distance(h.ort, f.ort) 20.000 1.000 1 Ergebnis: Hotels mit aufsteigender Entfernung zu TXL Zudem: x distance() ausführen Beispiele nach [CK97] Felix Naumann, VL Informationsintegration, WS 05/06

10 STOP AFTER – Syntax SELECT ... FROM ... WHERE ...
Selektion und Join-Bedingungen Projektion Relationen SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... STOP AFTER ... Gruppierung Sortierung Selektion nach Gruppierung STOP AFTER nach [CK97] Wichtig: Nicht SQL Standard! Neu: Beschränkung der Ergebniskardinalität Felix Naumann, VL Informationsintegration, WS 05/06

11 Felix Naumann, VL Informationsintegration, WS 05/06
STOP AFTER – Semantik Semantik: Führe sämtliches Standard-SQL in der Anfrage aus. Beschränke Ergebnis auf erste Tupel. Keine Sortierung Genaue Ergebnismenge nicht spezifiziert Sortierung Genaue Ergebnismenge spezifiziert, außer bei Duplikaten in Sortierungsattributen: Genaue Ergebnismenge nicht spezifiziert Weniger als N Tupel im Ergebnis: Kein Einfluss durch STOP AFTER Felix Naumann, VL Informationsintegration, WS 05/06

12 Felix Naumann, VL Informationsintegration, WS 05/06
STOP AFTER – Beispiel SELECT h.name, h.adresse, h.tel FROM hotels h, flughäfen f WHERE f.name = ‚TXL‘ ORDER BY distance(h.ort, f.ort) STOP AFTER 5 Ergebnis: 5 Hotels mit aufsteigender Entfernung zu TXL Einsparungen bei distance()? Felix Naumann, VL Informationsintegration, WS 05/06

13 Felix Naumann, VL Informationsintegration, WS 05/06
STOP AFTER – Beispiel SELECT p.name, v.umsatz FROM Produkte p, Verkäufe V WHERE p.typ = ‚software‘ AND p.id = v.prod_id ORDER BY v.umsatz DESC STOP AFTER ( SELECT count(*)/10 FROM Produkte p WHERE p.typ = ‚software‘) Liste Name und Umsatz der 10% umsatzstärksten Softwareprodukte. Felix Naumann, VL Informationsintegration, WS 05/06

14 Felix Naumann, VL Informationsintegration, WS 05/06
STOP AFTER – Updates UPDATE Spieler SET Gehalt = 0.5 * Gehalt WHERE id IN ( SELECT s.id FROM Spieler s ORDER BY s.tore STOP AFTER 3 ) Hertha BSC: - Kürze die Gehälter der 3 schlechtesten Spieler um 50%. Felix Naumann, VL Informationsintegration, WS 05/06

15 STOP AFTER – Implementierung
Implementierung in der Anwendung Keine Veränderung des DBMS Optimierungspotential nicht ausgeschöpft Implementierung in DBMS als äußere Schicht Einsparungen bei Datenübertragung Optimierungspotential nicht voll ausgeschöpft Implementierung im DBMS Kern Volles Optimierungspotential Schwieriger Felix Naumann, VL Informationsintegration, WS 05/06

16 Rückblick: Anfrageoptimierung
Umwandlung von SQL in interne Repräsentation Interne Operatoren Scan, Sort, Select, Project,... Interpretation als Baum Transformationsschritte im Baum Wahl des Schrittes gemäß Kostenmodell Felix Naumann, VL Informationsintegration, WS 05/06

17 Rückblick: Anfragebearbeitung
SELECT m.name FROM mitarbeiter m, abteilung a WHERE m.abt_id = a.id AND a.name = ‚Verkauf‘ ORDER BY m.gehalt In Worten? m.name(sortm.gehalt(m.abt_id = a.id, a.name = ‚Verkauf‘ (m x a))) Felix Naumann, VL Informationsintegration, WS 05/06

18 Rückblick: Anfragebearbeitung
m.name(sortm.gehalt(m.abt_id = a.id, a.name = ‚Verkauf‘ (m x a))) [20] (m.name) [20] (m.name) [20] [20] Sort(m.gehalt) Sort(m.gehalt) Einsparung a.Name = ‚Verkauf‘ [20] a.Name = ‚Verkauf‘ [20] [990] m.abt_id = a.id [990] ⋈m.abt_id = a.id [ ] X [1.000] [100] [1.000] [100] Mitarbeiter m Abteilung a Mitarbeiter m Abteilung a Felix Naumann, VL Informationsintegration, WS 05/06

19 Rückblick: Anfragebearbeitung
[20] [20] (m.name) (m.name) [20] [20] Sort(m.gehalt) Sort(m.gehalt) ? [20] a.Name = ‚Verkauf‘ [20] ⋈m.abt_id = a.id Einsparung [990] ⋈m.abt_id = a.id a.Name = ‚Verkauf‘ [5] [1.000] [100] [1.000] [100] Mitarbeiter m Abteilung a Mitarbeiter m Abteilung a Felix Naumann, VL Informationsintegration, WS 05/06

20 Felix Naumann, VL Informationsintegration, WS 05/06
Neuer Operator Logischer Operator Stop(N, Sortierungsrichtung, Sortierungsausdruck) N: maximale Ergebnisgroesse Sortierungsrichtung: asc, desc, none Sortierungsausdruck: meist wie ORDER BY Physikalische Operatoren Implementierungsvarianten des logischen Operators Scan-Stop Sort-Stop Jetzt! Felix Naumann, VL Informationsintegration, WS 05/06

21 Felix Naumann, VL Informationsintegration, WS 05/06
Scan-Stop Falls Sortierungsrichtung = ‚none‘ Schließt Input-Strom nach N Tupeln Kostenmodell p = Plan unterhalb (im Baum) Stop Operator s = Plan inkl. Stop Operator Cost(1) = Kosten für erstes Tupel (Latenz, latency) Costp(ALL) = Kosten für alle Tupel von p Pipelines werden bevorzugt! Warum? Felix Naumann, VL Informationsintegration, WS 05/06

22 Sort-Stop Falls Sortierungsrichtung = ‚asc/desc‘
Falls schon entsprechend sortiert: Schließt Input-Strom nach N Tupeln Kosten wie Scan-Stop Sonst sortieren: Erste N Tupel in priority-heap (Haufen) Nächste Tupel gegen Heap testen Kosten eines Vergleichs Input-Strom komplett erzeugen Test gegen Heap-Grenzen i Einfügungen in Heap N  i  ALL Felix Naumann, VL Informationsintegration, WS 05/06

23 Felix Naumann, VL Informationsintegration, WS 05/06
Überblick Anfragen nach den ERSTEN Ergebnissen (First-N) “Es reicht!“ in SQL [CK97] Syntax und Semantik Optimierung Anfragen nach den BESTEN Ergebnissen (Top-N) Motivation Fagin‘s Algorithm Felix Naumann, VL Informationsintegration, WS 05/06

24 Optimierung mit Stop-Operator
Platzierung des Stop Operators im Anfrageplan Fundamentales Problem: Frühe Platzierung vorteilhaft aber risikoreich Vorteil: Kleine Zwischenergebnisse  geringe Kosten Risiko: Endergebnis nicht groß genug  Erneute Ausführung Zwei Strategien „Konservativ“ und „aggressiv“ Felix Naumann, VL Informationsintegration, WS 05/06

25 Optimierung mit Stop-Operator
Konservative Strategie Kostenminimal: Platziere Stop so früh wie möglich in Plan. Korrekt: Platziere Stop nie so, dass Tupel entfernt werden, die später eventuell gebraucht werden. D.h.: Wende Stop nur auf Input-Ströme an, deren Input-Tupel jeweils mindestens ein Output-Tupel erzeugen. Operatoren, die Tupel filtern, müssen also früher ausgeführt werden. Felix Naumann, VL Informationsintegration, WS 05/06

26 Optimierung mit Stop-Operator
SELECT * FROM mitarbeiter m, abteilung a WHERE m.abt_id = a.id ORDER BY m.gehalt DESC STOP AFTER 10 Stop(10) sortStop m.abt_id NOT NULL m.abt_id ist Fremdschlüssel ⋈m.abt_id = a.id Unter welchen Bedingungen? Stop(10) sortStop ⋈m.abt_id = a.id Mitarbeiter m Abteilung a Mitarbeiter m Abteilung a Felix Naumann, VL Informationsintegration, WS 05/06

27 Optimierung mit Stop-Operator
SELECT * FROM mitarbeiter m, abteilung a WHERE m.abt_id = a.id AND a.name = ‚Verkauf‘ ORDER BY m.gehalt DESC STOP AFTER 10 Stop(10) sortStop ⋈m.abt_id = a.id Nein! Erlaubt? ⋈m.abt_id = a.id Stop(10) sortStop a.Name = ‚Verkauf‘ a.Name = ‚Verkauf‘ Mitarbeiter m Abteilung a Mitarbeiter m Abteilung a Felix Naumann, VL Informationsintegration, WS 05/06

28 Optimierung mit Stop-Operator
Aggressive Strategie Platziere Stop so früh wie möglich in Plan. Wähle (hoffentlich) hinreichend großes N: Füge „Reserve“ hinzu (z.B. 20%). Platziere weiteres, endgültiges Stop(N) später im Plan. Platziere geeignete „Restart“ Operatoren. Felix Naumann, VL Informationsintegration, WS 05/06

29 Optimierung mit Stop-Operator
SELECT * FROM mitarbeiter m, abteilung a, reisen r WHERE m.abt_id = a.id AND r.konto = m.reisekonto ORDER BY m.gehalt DESC STOP AFTER 10 Stop(10) ⋈m.abt_id = a.id Restart Abteilung a ⋈m.rkonto = r.konto Stop(20) sortStop Reise r Mitarbeiter m Felix Naumann, VL Informationsintegration, WS 05/06

30 Implementierungen von First N
SQL: select name, salary from employee A where 50 > (select count(*) from employee B where B.salary > A.salary) ...WHERE rownum < N MySQL: SELECT ...FROM ... LIMIT 10 DB2: FETCH FIRST N ROWS ONLY OPTIMIZE FOR N ROWS MS SQL Server SELECT TOP N ... FROM ... Oracle: OPTIMIZER_MODE = FIRST_ROWS_N Optimierung jeweils unklar! Weitere Optimierung („Bremsweg verkleinern“) z.B. in [CK98] Felix Naumann, VL Informationsintegration, WS 05/06

31 Felix Naumann, VL Informationsintegration, WS 05/06
Überblick Anfragen nach den ERSTEN Ergebnissen (First-N) “Es reicht!“ in SQL [CK97] Syntax und Semantik Optimierung Anfragen nach den BESTEN Ergebnissen (Top-N) Motivation Fagin‘s Algorithm Felix Naumann, VL Informationsintegration, WS 05/06

32 Anfragen nach den Top-N Ergebnissen – Motivation
First-N beschränkt Ergebnismenge aber nicht (unbedingt) Eigenschaften des Ergebnisses Ausnahme: Sortierung auf einem Attribut Top-N beschränkt Ergebnismenge und Eigenschaften Sortierung nach einem (beliebigen) Maß Maße sind oft fuzzy. Maße haben oft mehrere Attribute als Input. Felix Naumann, VL Informationsintegration, WS 05/06

33 Anfragen nach den Top-N Ergebnissen – Beispiele
Suchmaschinen Maß: Vorkommen des Suchworts & „authority“ Information Retrieval Maß: Relevanz In DBMS 4-Zimmer Wohnungen, unter $30,000 Bisher nicht unterstützt In Multimedia DBMS Bilder mit roten und runden Objekten Felix Naumann, VL Informationsintegration, WS 05/06

34 Top-N in Multimedia DBMS
Farb-Ähnlichkeit Z.B. Anfrage: Farbe = ‚rot‘ Berechnung der „Röte“ oft komplex (viele Farbdimensionen, viele Pixel) MMDBMS liefert top-N roteste (röteste?) Objekte Multidimensionale Indices Form-Ähnlichkeit Z.B. Anfrage: Form = ‚rund‘ Berechnung der „Rundheit“ oft komplex MMDBMS liefert top-N rundeste Objekte Entspricht First-N Semantik (Maß auf einem Attribut) Aber wie kombinieren? Felix Naumann, VL Informationsintegration, WS 05/06

35 Top-N in Multimedia DBMS
Beatles „Red Album“ Anfrage: Farbe = ‚rot‘  Name = ‚Beatles‘ Was als Antwort: Menge? Sortierte Liste? Fuzzy Prädikat Antwort ist sortierte Liste Non-Fuzzy Prädikat Antwort ist (unsortierte) Menge Felix Naumann, VL Informationsintegration, WS 05/06

36 Top-N in Multimedia DBMS
Anfrage: Farbe = ‚rot‘  Name = ‚Beatles‘ Antwort: Menge? Sortierte Liste? Anfrage: Farbe = ‚rot‘  Form = ‚rund‘ Antwort: Menge? Sortierte Liste? Idee [Fa96]: Antwort ist „benotete Menge“ („graded set“) Felix Naumann, VL Informationsintegration, WS 05/06

37 Top-N – benotete Mengen
Menge aus Paaren (x,g) x ist ein Objekt g  [0,1] ist eine Note (grade) Anfrage: Name = ‚Beatles‘ Antwort: benotete Menge mit g  {0,1} Anfrage: Farbe = ‚rot‘ Antwort: benotete Menge mit g  [0,1] Felix Naumann, VL Informationsintegration, WS 05/06

38 Top-N – benotete Mengen
Anfrage: Name = ‚Beatles‘  Farbe = ‚rot‘ Name = ‚Beatles‘  Farbe = ‚rot‘ Problem: Maß: Benotung der Objekte in Antwort Sei gA(x) die Note von Objekt x unter Anfrage A. Erwünschte Eigenschaften Falls g  {0,1} sollte Standard-Logik gelten. Bewahrung der logischen Äquivalenz gAA(x) = gA(x) gA(B C)(x) = g(AB)  (A  C)(x) Monotonie: gA(x)  gA(y), gB(x)  gB(y)  gAB(x)  gA B(y) Felix Naumann, VL Informationsintegration, WS 05/06

39 Top-N – benotete Mengen
Vorschlag Konjunktionsregel [Za65]: gAB(x) = min{gA(x), gB(x)} Disjunktionsregel [Za65]: gAB(x) = max{gA(x), gB(x)} Felix Naumann, VL Informationsintegration, WS 05/06

40 Top-N – benotete Mengen
gAB(x) = min{gA(x), gB(x)}, gAB(x) = max{gA(x), gB(x)} Standardlogik (g  {0,1}) 0  1 = min{0,1} = 0 0  1 = max{0,1} = 1 Äquivalenz gAA(x)= min{gA(x), gA(x)} = gA(x) gA(B C)(x) = min{gA(x), max{gB(x), gC(x)}} = max{min{gA(x), gB(x)}, min{gA(x), gC(x)}} = g(AB)  (A  C)(x) Monotonie gA(x)  gA(y), gB(x)  gB(y)  gAB(x)  gA B(y) gA(x)  gA(y), gB(x)  gB(y)  min{gA(x), gB(x)}  min{gA(y), gB(y)} Felix Naumann, VL Informationsintegration, WS 05/06

41 Felix Naumann, VL Informationsintegration, WS 05/06
Andere Maße? AVG gAB(x) = avg{gA(x), gB(x)}, gAB(x) = max{gA(x), gB(x)} 0  1 = avg{0,1} = 0.5 0  1 = max{0,1} = 1 gAA(x)= avg{gA(x), gA(x)} = gA(x) gA(B C)(x) = avg{gA(x), max{gB(x), gC(x)}} = max{avg{gA(x), gB(x)}, avg{gA(x), gC(x)}} = g(AB)  (A  C)(x) gA(x)  gA(y), gB(x)  gB(y)  avg{gA(x), gB(x)}  avg{gA(y), gB(y)} D.h. Standardlogik bleibt nicht erhalten. Name = ‚Beatles‘  Farbe = ‚rot‘ Album (Santana, Supernatural) hat score > 0 Fast jedes andere Album hat auch score > 0 Felix Naumann, VL Informationsintegration, WS 05/06

42 Top-N – Fagin‘s Algorithmus
Gegeben: Konjunktive Anfrage mit teilweise fuzzy Prädikaten. Gesucht: Benotete Menge mit mindesten Top-N Objekten Zugriffsmodell auf MMDBMS Sorted access: Cursor auf sortierte Liste Random access: Note eines bestimmten Objekts Kostenmodell: Jedes angefragte Objekt kostet 1. Optimierung: Minimiere Kosten Felix Naumann, VL Informationsintegration, WS 05/06

43 Top-N – Beispiel Anfrage: Name = ‚Beatles‘  Farbe = ‚rot‘
G = min{1,gFarbe = ‚rot‘(x)} ⋈s.id = p.id random access Name = ‚Beatles‘ Kosten? DBMS Schallplatten MMDBMS Plattencover Felix Naumann, VL Informationsintegration, WS 05/06

44 Top-N – Naiver Algorithmus
Anfrage: Form = ‚rund‘  Farbe = ‚rot‘ Sorted access auf alle Objekte (mit Note für Form = ‚rund‘) Sorted access auf alle Objekte (mit Note für Farbe = ‚rot‘) Join über alle Objekte x Jeweils Berechnung der minimalen Note min{grund(x),grot(x)} Sortierung für Top-N Kosten 2n (2x sorted access) Felix Naumann, VL Informationsintegration, WS 05/06

45 Top-N – Beispiel Anfrage: Form = ‚rund‘  Farbe = ‚rot‘ ⋈s.id = p.id
G = min{gForm = ‚rund‘(x),gFarbe = ‚rot‘(x)} ⋈s.id = p.id sorted access sorted access/random access MMDBMS_1 Plattencover (Formen) MMDBMS_2 Plattencover (Farben) Felix Naumann, VL Informationsintegration, WS 05/06

46 Felix Naumann, VL Informationsintegration, WS 05/06
Überblick Anfragen nach den ERSTEN Ergebnissen (First-N) “Es reicht!“ in SQL [CK97] Syntax und Semantik Optimierung Anfragen nach den BESTEN Ergebnissen (Top-N) Motivation Fagin‘s Algorithm Felix Naumann, VL Informationsintegration, WS 05/06

47 Top-N – Fagins Algorithmus
Allgemeineres Problem: Anfrage statt A  B nun A1  A2  ...  Am Für jedes Prädikat eine Quelle. bzw. Zugriffsmöglichkeit durch sorted und random access Phase 1: Sorted access Phase 2: Random access Phase 3: Berechnung und Sortierung Felix Naumann, VL Informationsintegration, WS 05/06

48 Top-N – Fagins Algorithmus
A1  A2  ...  Am Phase 1: Sorted access Für jedes i: Schicke Ai an Quelle i Schreite sukzessive voran, bis Join über alle Teilergebnisse die Größe N hat. ⋈id ... MMDBMS_1 MMDBMS_2 MMDBMS_m Felix Naumann, VL Informationsintegration, WS 05/06

49 Top-N – Fagins Algorithmus
Objekte aus MMDBMS_2 mit gA2(x) Objekte aus MMDBMS_1 mit gA1(x) N N Objekte aus allen MMDBMS mit allen gAi(x) also auch mit Gesamt-Note Objekte aus MMDBMS_2 und MMDBMS_m mit gA1(x) und gAm(x) ... MMDBMS_1 MMDBMS_2 MMDBMS_m Felix Naumann, VL Informationsintegration, WS 05/06

50 Top-N – Fagins Algorithmus
Der Clou: Unter allen gesehenen Objekten befinden sich auch die Top-N Objekte. Beweis später. Wichtig: Dies sind nicht unbedingt die Top-N Objekte! N ... MMDBMS_1 MMDBMS_2 MMDBMS_m Felix Naumann, VL Informationsintegration, WS 05/06

51 Top-N – Fagins Algorithmus
Phase 2: Random access Hole alle unbekannten gAi(x) ein. Ergebnis: Nun kennen wir alle Noten aller gesehenen Objekte. N ... MMDBMS_1 MMDBMS_2 MMDBMS_m Felix Naumann, VL Informationsintegration, WS 05/06

52 Top-N – Fagins Algorithmus
Phase 3: Berechnung und Sortierung Berechne für jedes Objekt gA1  A2  ...  Am(x) = min{gA1(x), gA2(x),..., gAm(x)} Sortiere alle Objekte nach gA1  A2  ...  Am(x) Selektierte die höchsten N Objekte. Ausgabe dieser Top-N Objekte. Felix Naumann, VL Informationsintegration, WS 05/06

53 Fagins Algorithmus – Beispiel
Anfrage: Form = ‚rund‘  Farbe = ‚rot‘  Stil = ‚Modern‘ N = 2 MMDBMS_1 MMDBMS_2 MMDBMS_3 ID Form Rundheit 1 oval 0.8 2 achteck 0.6 3 viereck 0.15 4 dreieck 0.1 5 strich ID Stil Modernität 3 modern 1 2 rock 0.7 4 barock 0.2 keltisch 0.1 5 uralt 0.01 ID Farbe Rotheit 3 rot 1 2 orange 0.5 gelb 0.3 4 blau 0.01 5 grün Felix Naumann, VL Informationsintegration, WS 05/06

54 Fagins Algorithmus – Beispiel
4:(??; 0.2; ??) 4 3:(0.15; 1; 1) 3 2 1 2:(0.6; 0.7; 0.5) 1:(0.8; ??; 0.3) ID Form Rundheit 1 oval 0.8 2 achteck 0.6 3 viereck 0.15 4 dreieck 0.1 5 strich ID Stil Modernität 3 modern 1 2 rock 0.7 4 barock 0.3 keltisch 0.2 5 uralt 0.01 ID Farbe Rotheit 3 rot 1 2 orange 0.5 gelb 0.3 4 blau 0.01 5 grün Felix Naumann, VL Informationsintegration, WS 05/06

55 Top-N – Fagins Algorithmus
Korrektheit: Fagins Algorithmus findet die Top-N Objekte gemäß gA(x). Beweis: Idee: Wir zeigen für jedes ungesehene Objekt y, dass es nicht unter den Top-N sein kann: Notation x: gesehene Objekte y: ungesehene Objekte Für jedes x der Joinmenge nach Phase 1 und jedes Prädikat Ai gilt: gAi(y)  gAi(x). Wegen Monotonie von min{} gilt: gA1  A2  ...  Am(y)  gA1  A2  ...  Am(x). Es gibt mindesten N solcher Objekte x (Abbruch-Kriterium Phase 1). Schlussfolgerung: Es gibt kein y, das besser ist als die besten N x. Wichtig: Wir können dies nicht für andere gesehene Objekte zeigen. Felix Naumann, VL Informationsintegration, WS 05/06

56 Top-N – Fagins Algorithmus
Aufwand: O(n(m-1)/mN1/m) (Beweis: siehe [Fa96]) n = DB-Größe; m = Anzahl der DBs Beispiel: Objekte, 3 Prädikate, Top 10 /3 x 101/3 = 1.000 Gilt falls Ai unabhängig. Gilt mit beliebig hoher Wahrscheinlichkeit. D.h.: Für jedes ε>0  c, so dass die Wahrscheinlichkeit dass der Aufwand höher ist als angegeben < ε ist. Zum Vergleich: Naiver Algorithmus in O(nm) Im Beispiel: x 3 = Felix Naumann, VL Informationsintegration, WS 05/06

57 Fagins Algorithmus in der Praxis
Probleme aus [WHTB99] Monotonie Vorgabe einer festen Menge (monotoner) Maße oder Nutzerimplementation erlauben? WHERE Klausel oder ORDER BY Klausel Charakter des Algorithmus Join über mehrere Quellen Objektidentifikation Kostenmodell schwierig Felix Naumann, VL Informationsintegration, WS 05/06

58 Top-N Anfragen – Herausforderungen
Beliebige Maße Je nach Nutzer bzw. Anwendung Effiziente Ausführung in bestehenden DBMS Unter Ausnutzung vorhandener Datenstrukturen und Metadaten Korrektheit und Vollständigkeit Idee: Wandele Top-N Anfragen in herkömmliche Anfragen um [CG99]. Felix Naumann, VL Informationsintegration, WS 05/06

59 Felix Naumann, VL Informationsintegration, WS 05/06
Rückblick First-N Syntax und Semantik Optimierung Top-N Motivation Fagins Algorithmus Felix Naumann, VL Informationsintegration, WS 05/06

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

61 Felix Naumann, VL Informationsintegration, WS 05/06
Literatur First-N [CK97] Michael J. Carey, Donald Kossmann: On Saying "Enough Already!" in SQL. SIGMOD Conference 1997: [CK98] Michael J. Carey, Donald Kossmann: Reducing the Braking Distance of an SQL Query Engine. VLDB 1998: Top-N [Fa98] Ronald Fagin: Fuzzy Queries in Multimedia Database Systems. PODS 1998: 1-10 Weitere [CG99] Surajit Chaudhuri, Luis Gravano: Evaluating Top-k Selection Queries. VLDB 1999: [DR99] Donko Donjerkovic, Raghu Ramakrishnan: Probabilistic Optimization of Top N Queries. VLDB 1999: [Za65] Lotfi A. Zadeh: Fuzzy Sets. Information and Control 8(3): (1965) [DP84] D, Dubois and H. Prade, Criteria Aggregation and Ranking of Alternatives in the Framework of Fuzzy Set Theory, in Fuzzy Sets and Decision Analysis, TIMS Studies in Management Sciences 20 (1984), pp [WHTB99] Edward L. Wimmers, Laura M. Haas, Mary Tork Roth, Christoph Braendli: Using Fagin's Algorithm for Merging Ranked Results in Multimedia Middleware. CoopIS 1999: Felix Naumann, VL Informationsintegration, WS 05/06


Herunterladen ppt "Informationsintegration Top-N Anfragen"

Ähnliche Präsentationen


Google-Anzeigen