SlideShare a Scribd company logo
Query Rewriting and Optimization 
for Ontological Databases! 
Georg Gottlob, Giorgio Orsi, and Andreas Pieris! 
name.surname@cs.ox.ac.uk! 
! 
! 
Department of Computer Science! 
Oxford University! 
! 
Dagstuhl 2014 
References: !Gottlob et Al. Query Rewriting and Optimization for Ontological Databases. 
! ! ! ACM TODS 2014.
Ontological query answering 
query 
theory 
? 
Q 
⌃ 
D 
database
Ontological query answering 
query 
theory 
? 
Q 
⌃ 
D 
database 
chasing is an option but we would like to use a DBMS to answer the query.
Our setting: 
The constraint language: 
tuple-generating dependencies (TGDs) 
8X8Y '(X,Y) ! 9Z (X,Z) 
8X '(X) ! Xi = Xj equality-generating dependencies (EGDs) 
8X '(X)!? negative constraints (NCs) 
Query language: 
Q : 9Y'(X,Y) conjunctive queries (CQs) 
EGDs and NCs that are well-behaved can be checked beforehand and 
then ignored during the rewriting (i.e., non conflicting, separable).
FO-rewritability 
Very well known in the DL area [Calvanese et Al. JAR’07] 
Q ⌃ 
Q⌃ 
rewrite 
using 
D 
8D : chase(D,⌃) |= Q $ D |= Q⌃
Concrete FO-rewritable classes 
Linear TGDs 
one body atom (generalize IDs) 
[Cali et Al. PODS’09] 
8X8Y8Z r(X,Y) ! 9Z (X,Z) 
Sticky TGDs 
0:12 t(X,Y,Z) → ∃W s(Y,W) 
[Cali et Al. VLDB’10] 
Join variables stick to the inferred atoms 
Abstract classes 
Finite unification sets FUS [Baget et Al. AIJ’11] 
r(X,Y),p(Y,Z) → ∃W t(X,Y,W) 
r(X,Y),p(Y,Z) → ∃W t(X,Y,W) 
t(X,Y,Z) → ∃W s(X,W) 
× 
√ 
(a) Fig. 3. Sticky property and propagation
Bounded derivation depth property 
[Cali et Al. PODS’09] 
BDDP ) (positive) first-order rewritability 
Q 
D 
chase(D,Σ) 
depth depends on 
Q and Σ 
but not on D
BDDP rewriting 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A, db,B) 
[Cali et Al. PODS’09]: enumerate all the possible ancestor databases such 
that the input query maps to their chase.
BDDP rewriting 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A, db,B) 
[Cali et Al. PODS’09]: enumerate all the possible ancestor databases such 
that the input query maps to their chase. 
D 
hasCollaborator(a, db, b) 
D⌃ hasCollaborator (a, db, b) 
collaborator (a) 
Q maps! 
constants fromQ 
frozen nulls 
Q1 : 9AhasCollaborator(A, db,B)
BDDP rewriting 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A, db,B) 
[Cali et Al. PODS’09]: enumerate all the possible ancestor databases such 
that the input query maps to their chase. 
D D 
… 
hasCollaborator(a, db, b) 
Q maps! 
inArea(a, db) 
project(a) 
inArea(a, db) D⌃ 
project(a) 
Q1 : 9AhasCollaborator(A, db,B) 
Q maps! 
Q2 : project(A), inArea(A, db) 
D⌃ hasCollaborator (a, db, b) 
collaborator (a) hasCollaborator(z0, db, a) 
collaborator (z0) 
constants fromQ 
frozen nulls
BDDP rewriting 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A, db,B) 
[Cali et Al. PODS’09]: enumerate all the possible ancestor databases such 
that the input query maps to their chase. 
D D 
… 
hasCollaborator(a, db, b) 
Q maps! 
inArea(a, db) 
project(a) 
inArea(a, db) D⌃ 
project(a) 
Q1 : 9AhasCollaborator(A, db,B) 
Q maps! 
Q2 : project(A), inArea(A, db) 
Q⌃ : Q1 _ Q2 _ . . . 
D⌃ hasCollaborator (a, db, b) 
collaborator (a) hasCollaborator(z0, db, a) 
collaborator (z0) 
constants fromQ 
frozen nulls
Backward resolution 
[Calvanese et Al. JAR’07, Cali et Al. AMW’10]: 
Construct a (perfect) rewriting via backward resolution. 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A,B,C), collaborator (A)
Backward resolution 
[Calvanese et Al. JAR’07, Cali et Al. AMW’10]: 
Construct a (perfect) rewriting via backward resolution. 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A,B,C), collaborator (A) 
Step 1: rewriting 
Q : 9A hasCollaborator(A,B,C), collaborator (A) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X)
Backward resolution 
[Calvanese et Al. JAR’07, Cali et Al. AMW’10]: 
Construct a (perfect) rewriting via backward resolution. 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Step 1: rewriting 
Q : 9A hasCollaborator(A,B,C), collaborator (A) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
μ : {X7! A} 
Q : 9A hasCollaborator(A,B,C), collaborator (A)
Backward resolution 
[Calvanese et Al. JAR’07, Cali et Al. AMW’10]: 
Construct a (perfect) rewriting via backward resolution. 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Q : 9A hasCollaborator(A,B,C), collaborator (A) 
Step 1: rewriting 
Q : 9A hasCollaborator(A,B,C), collaborator (A) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
μ : {X7! A} 
Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1)
Careful with MGUs! 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
unsound rewriting 
Q : hasCollaborator(a, b,C) 
μ : {Z7! a, Y7! b,X7! C} 
Q0 : project(C), inArea(C, b)
Careful with MGUs! 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
unsound rewriting 
Q : hasCollaborator(a, b,C) 
μ : {Z7! a, Y7! b,X7! C} 
Q0 : project(C), inArea(C, b) 
D 
project(a) 
inArea(a, b) 
D⌃ project(a) 
inArea(a, b) 
hasCollaborator(z0, b, a) 
Q does not map here but Q0 does! 
Applicability: prevent MGUs which unify existential 
variables with join variables (included self) and 
constants.
Backward resolution 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Step 2: minimization 
Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1)
Backward resolution 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Step 2: minimization 
Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1) 
stuck! Applicability prevents us from rewriting. Rewriting is still incomplete.
Backward resolution 
1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 
2 : hasCollaborator(X, Y ,Z) ! collaborator(X) 
Step 2: minimization 
Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1) 
stuck! Applicability prevents us from rewriting. Rewriting is still incomplete. 
subquery 
μ : {V07! B, V17! C} 
(different from Chandra  Merlin) 
Q00 : 9A hasCollaborator(A,B,C) 
now we can rewrite with 2 
Loop until no more steps are applicable. 
In general, this process might not terminate, each class of TGDs might 
require a different stop condition (exploit linearity and stickiness).
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
Only those which free shared existential variables are useful reductions 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D)
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
Only those which free shared existential variables are useful reductions 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} 
Q0 : 9B9D r(C,B), r(B,D) B is still shared!
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
Only those which free shared existential variables are useful reductions 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} 
Q0 : 9B9D r(C,B), r(B,D) B is still shared! 
Piece unifiers, factorizations [Baget et Al. ICCS’96, Gottlob et Al. ICDE ’11]. 
 : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) 
Q1 : 9B9C t(a,A,C), t(B, a,C)
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} 
Q0 : 9B9D r(C,B), r(B,D) B is still shared! 
Backward resolution still complete if we perform only those that free shared 
existential variables [Baget et Al. ICCS’96] 
Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. 
 : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) 
Q1 : 9B9C t(a,A,C), t(B, a,C)
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} 
Q0 : 9B9D r(C,B), r(B,D) B is still shared! 
Backward resolution still complete if we perform only those that free shared 
existential variables [Baget et Al. ICCS’96] 
Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. 
 : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) 
Q1 : 9B9C t(a,A,C), t(B, a,C) 
Q2 : 9B9C9E s(C), t(A,B,C), t(A,E,C)
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} 
Q0 : 9B9D r(C,B), r(B,D) B is still shared! 
Backward resolution still complete if we perform only those that free shared 
existential variables [Baget et Al. ICCS’96] 
Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. 
 : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) 
Q1 : 9B9C t(a,A,C), t(B, a,C) 
Q2 : 9B9C9E s(C), t(A,B,C), t(A,E,C) 
Q3 : 9B9C t(A,B,C), t(A,C,C)
Opt. 1: Factorization 
Exhaustive minimisations are not necessary. 
 : s(X) ! 9Y r(X, Y ) 
Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} 
Q0 : 9B9D r(C,B), r(B,D) B is still shared! 
Backward resolution still complete if we perform only those that free shared 
existential variables [Baget et Al. ICCS’96] 
Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. 
 : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) 
Q1 : 9B9C t(a,A,C), t(B, a,C) 
Q2 : 9B9C9E s(C), t(A,B,C), t(A,E,C) 
Q3 : 9B9C t(A,B,C), t(A,C,C)
Opt. 2: Atom coverage 
Queries can be reduced during rewriting. 
We eliminate rewriting steps! 
 : t(X, Y ) ! 9Z r(X, Y ,Z) 
Q : 9B9C t(A,B), r(A,B,C), s(A,B,B)
Opt. 2: Atom coverage 
Queries can be reduced during rewriting. 
We eliminate rewriting steps! 
 : t(X, Y ) ! 9Z r(X, Y ,Z) 
Q : 9B9C t(A,B), r(A,B,C), s(A,B,B) 
 r(A,B,C) 
Under the atom can be eliminated, obtaining an (equivalent) query 
Q0 : 9B t(A,B), s(A,B,B) 
Chase and Backchase [Deutsch et Al. PODS’08, Maier VLDBJ’14] 
But… chase is of exponential size and has to be constructed for (worst-case) 
exponentially many queries.
Opt. 2: Atom coverage 
For linear TGDs (one body atom), it amounts to reachability in a graph 
(but we lose some implications…). 
 : t(X, Y ) ! 9Z r(X, Y ,Z) 
Precompute a propagation graph 
t[1] 
t[2] 
r[1] 
r[2] 
r[3] 
Roughly: 
check that it is possible to propagate terms 
from the covering atom to the covered one 
using the same sequence of TGDs 
The elimination strategy is unique w.r.t. the 
size (number of atoms) of the resulting query. 
 
 
Q : 9B9C t(A,B), r(A,B,C), s(A,B,B)
Opt. 2: Atom coverage 
Instead of testing reachability we can use a cover graph 
Q(ui.eery., Rthewe rtitriangnsanitdivOe pctilmoiszuatrieon ofof rthOen tpolroogpicaalgDaatitoabna gsersaph). 0:41 
Table IV. Propagation and cover graphs. 
Size (#nodes,#edges) LP Time (ms) Memory 
P-GRAPH C-GRAPH C-GRAPHP-GRAPHC-GRAPHP-GRAPHC-GRAPH 
V (214,445) (214,1194) 7 4 158 190Kb 4.7Mb 
S (41,103) (41,405) 8 1 120 45Kb 4,4Mb 
U (86,189) (86,416) 6 1 37 81Kb 4.4Mb 
A (135,319) (135,1133) 10 43 708 154Kb 4.7Mb 
P5 (15,32) (15,43) 3 0 1 14Kb 4.3Mb 
SF (100,195) (100,1,050) 19 1 346 84Kb 4.8Mb 
CLQ (11,143) N/A N/A 2 N/A 39Kb N/A 
Differently from the query graph, the propagation and the cover graph depend only 
on the input ontology and not on the input query. Table IV reports the characteristics 
of The both cover the propagation graph becomes graph (unmanageable P-GRAPH) and the for cover large graph ontologies (C-GRAPH) (Galen constructed 
lite). 
for each ontology. In particular, we report on the size of the two structures in terms 
of Either the number pay the of reachability nodes and edges, price on the the time propagation necessary to graph construct (use a them, graph and DB). 
their 
memory footprint. For the cover graph, we also report the length of the longest label 
on an edge (LP), corresponding to the longest tight sequence of TGDs that we have to 
consider during the computation of cover sets. Since query elimination can be applied
ImQuperyaRecwrtitin goandfO pmtimizaitnionifomr OntiolzogiacaltDaitoabanses 0:37 
Table I. The impact of query elimination on the rewriting. 
Size #Atoms #Joins Explored Generated Time (ms) Memory (MB) 
BASE QE BASE QE BASE QE BASE QE BASE QE BASE QE BASE QE 
V 
q1 15 15 15 15 0 0 15 15 14 14 9 9 4.3 4.3 
q2 10 10 30 30 30 30 10 10 9 9 7 7 4.3 6.3 
q3 72 72 216 216 144 144 72 72 71 71 44 45 4.7 6.7 
q4 185 185 555 555 370 370 185 185 184 184 111 115 5.4 7.4 
q5 30 30 210 210 270 270 30 30 29 29 26 28 4.6 6.6 
S 
q1 6 6 6 6 0 0 6 6 7 7 2 2 4.1 4.1 
q2 160 2 480 2 320 0 160 2 244 1 43 2 5.9 8.2 
q3 504 4 2,520 8 2,520 4 504 4 823 3 198 8 16.8 8.2 
q4 960 4 4,800 8 4,800 4 960 4 1,445 3 363 2 25.3 8.2 
q5 3,024 8 21,168 24 27,216 24 3,024 8 4,892 7 1.7s 3 12.6 8.3 
U 
q1 2 2 4 4 2 2 5 5 4 4 3 3 4.1 6.2 
q2 148 1 444 1 296 0 240 1 250 0 73 1 5.8 4.1 
q3 224 4 1,344 16 2,016 20 1,008 12 1,007 11 432 7 18.5 8.3 
q4 1,628 2 4,884 2 1,628 0 5,000 5 6,094 4 1.6s 3 54.1 8.2 
q5 3,009 10 12,036 20 18,054 20 8,154 25 11,970 24 3.2s 8 119.2 8.4 
A 
q1 402 299 779 573 377 274 782 679 847 725 818 729 7.9 17.0 
q2 103 94 256 238 153 144 1,784 1,772 1,783 1,783 1.1s 1.2s 19.1 33.4 
q3 104 104 520 520 520 520 4,752 4,752 4,751 4,751 3.2s 3.5s 62.7 97.5 
q4 492 456 1,288 1,216 796 760 7,110 6,740 7,110 6,838 3.8s 3.5s 67.8 65.8 
q5 624 624 3,120 3,120 3,120 3,120 76,12269,44876,12170,457 52.3s 49.8s 1.1G 981.5 
P5 
q1 6 6 6 6 0 0 14 14 13 13 1 2 4.1 4.1 
q2 10 10 16 16 6 6 77 77 76 80 55 8 4.5 8.6 
q3 13 13 29 29 16 16 410 400 409 413 57 52 7.4 11.4 
q4 15 15 44 44 29 29 2,275 2,210 2,274 2,273 368 403 30.3 33.5 
q5 16 16 60 60 44 44 13,52213,08513,52113,424 3.2s 3.2s 211.7 208.3 
SF 
q1 1 1 3 3 2 2 1 1 0 0 1 1 0.053 2.1 
q2 125 125 375 375 250 250 125 125 124 124 30 33 5.1 7.1 
q3 1,000 1,000 3,000 3,000 2,000 2,000 1,000 1,000 999 999 227 237 12.6 14.7 
q4 8,000 8,000 24,000 24,000 16,000 16,000 8,000 8,000 7,999 7,999 2s 2.2s 77.2 77.0 
q5 27,00027,000162,000162,000108,000108,00027,00027,00026,99926,999 12.4s 12.4s 560.7 561.6
Parallelization 
Q 
splitter 
Q1 Q2 … Qn 
merger 
Q⌃
Parallelization 
The rewriting can be computed in parallel by decomposing the query 
1 : p(X, Y ), s(Y ,Z) ! 9W t(Y ,X,W) 
2 : t(X, Y ,Z) ! 9W p(W,Z) 
1 : {t[3], p[2]} 
2 : {p[1], t[2]} 
Q : q(A,D) p(D,B), t(A,B,C), p(E,C) 
Atoms that do not join on existential positions can be rewritten independently. 
Q1 : q1(A,B) t(A,B,C), p(E,C) 
Q2 : q2(D,B) p(D,B) 
Bind in the head of the component 
distinguished and cross-component 
join variables. 
reconciliation rule. 
Q⇢ : q(A,D) q1(A,B), q2(D,B) 
Then, unfold using the reconciliation rule.
Impa0:38ct of parallelization G. Gottlob et al. 
Table II. The impact of parallelization on the rewriting. 
Size Explored Generated Time (ms) Memory (MB) 
Comp BASE PARA BASE PARA BASE PARA BASE PARA Rew Split Unfold BASE PARA 
V 
q1 1 15 15 15 15 14 14 9 14 14 0 0 4.3 4.3 
q2 3 10 10 10 12 9 9 7 4 3 1 0 6.3 6.4 
q3 3 72 72 72 28 71 25 45 25 24 1 2 6.7 6.7 
q4 3 185 185 185 43 184 40 115 26 26 0 3 7.5 7.4 
q5 7 30 30 30 14 29 7 28 16 16 0 2 6.6 6.7 
S 
q1 1 6 6 6 6 7 7 2 2 2 0 0 4.2 4.2 
q2 1 2 2 2 2 1 1 2 2 1 0 0 8.2 8.2 
q3 1 4 4 4 4 3 3 8 3 2 0 0 8.2 8.2 
q4 2 4 4 4 4 3 2 2 3 2 0 0 8.2 8.2 
q5 2 8 8 8 6 7 4 3 4 3 1 0 8.3 8.3 
U 
q1 2 2 2 5 6 4 4 3 4 3 0 0 6.2 6.2 
q2 1 1 1 1 1 0 0 1 1 1 0 0 4.1 4.1 
q3 4 4 4 12 9 11 5 7 4 3 1 1 8.3 8.3 
q4 1 2 2 5 5 4 4 3 3 2 0 0 8.2 8.2 
q5 2 10 10 25 10 24 8 8 5 5 0 0 8.3 8.3 
A 
q1 1 299 299 679 679 725 725 729 282 281 1 0 17.0 17.0 
q2 1 94 94 1,772 1,772 1,783 1,783 1.2s 853 852 1 0 33.4 33.4 
q3 3 104 104 4,752 4,754 4,751 4,751 3.5s 2.5s 2.5s 3 7 97.5 49.8 
q4 1 456 456 6,740 6,740 6,838 6,838 3.5s 3.5s 3.5s 1 0 65.9 93.9 
q5 2 624 624 69,448 69,449 70,457 70,486 49.8s 43.4s 43.4s 5 18 981.5 865.0 
P5 
q1 1 6 6 14 14 13 13 2 2 1 0 0 4.1 4.1 
q2 1 10 10 77 77 80 80 8 9 8 0 0 8.6 8.6 
q3 1 13 13 400 400 413 413 52 61 61 0 0 11.4 11.4 
q4 1 15 15 2,210 2,210 2,273 2,273 403 400 399 1 0 33.5 33.5 
q5 1 16 16 13,085 13,085 13,424 13,424 3.2s 3.1s 3.1s 0 0 208.2 208.6 
SF 
q1 3 1 1 1 3 0 0 1 3 2 1 1 2.1 6.2 
q2 3 125 125 125 15 124 12 33 6 5 0 1 7.1 6.6 
q3 3 1,000 1,000 1,000 30 999 27 237 15 14 1 10 14.7 9.1 
q4 3 8,000 8,000 8,000 60 7,999 57 2.2s 82 82 0 73 770.4 274.4 
q5 6 27,000 27,000 27,000 39 26,999 33 12.4s 472 471 1 464 561.6 121.4 
CLQ 
q1 1 38 38 38 38 57 57 102 8 8 0 0 4.6 4.6 
q2 2 38 38 38 39 54 56 140 15 14 1 1 4.6 4.7 
q3 4 152 152 152 44 223 59 864 17 17 0 6 7.5 5.5 
q4 5 5,776 5,776 5,776 82 9,871 112 48.3s 317 316 1 304 287.4 87.08
A note on subsumption check 
A classic optimization mechanism (but expensive) is subsumption check 
Q1 subsumes Q2 if there exists μ such that μ(body(Q1)) ✓ body(Q2) and 
μ(head(Q1)) = head(Q2) 
Remove the subsumed queries from the rewriting. 
Three modes: 
• TAIL, at the end of the rewriting procedure (guarantees minimality) 
• intra-rewriting (IREW), after each rewriting step (guarantees minimality) 
• Careful! the rewriting operator must be prunable [Konig et Al. SWJ ’14] 
• intra-decomposition (IDEC), like TAIL but for each component (parallel version)
ImpaQcuetry Reowritfin g asnduOptbimizsatioun fomr OntoplogitcaliDoatanbase scheck 0:39 
Table III. The impact of subsumption check on the rewriting. 
Size Explored Generated Time (ms) Memory (MB) 
BASE TAIL IDEC IREW BASE IREW BASE IREW BASE TAIL IDECIREWBASE TAIL IDECIREW 
V 
q1 15 15 15 15 15 15 14 14 14 12 13 10 4.3 4.3 4.3 4.3 
q2 10 10 10 10 12 12 9 9 4 9 7 26 6.4 6.4 6.4 6.4 
q3 72 72 72 72 28 28 25 25 25 28 15 24 6.6 6.6 6.6 6.6 
q4 185 185 185 185 43 43 40 40 26 75 28 55 7.4 7.4 7.4 7.4 
q5 30 30 30 30 14 14 7 7 16 12 11 14 6.7 6.7 6.7 6.7 
S 
q1 6 6 6 6 6 6 7 7 2 2 3 3 4.2 4.2 4.2 4.2 
q2 2 2 2 2 2 2 1 1 2 2 3 2 8.2 8.2 8.2 8.2 
q3 4 4 4 4 4 4 3 3 3 3 3 2 8.3 8.3 8.3 8.3 
q4 4 4 4 4 4 4 2 2 3 3 4 5 8.3 8.3 8.3 8.3 
q5 8 8 8 8 6 6 4 4 4 3 6 5 8.3 8.3 8.3 8.3 
U 
q1 2 2 2 2 6 6 4 4 4 4 6 5 6.2 6.2 6.2 6.2 
q2 1 1 1 1 1 1 0 0 1 1 1 2 4.2 4.2 4.2 4.2 
q3 4 4 4 4 9 9 5 5 4 4 3 5 8.3 8.3 8.3 8.3 
q4 2 2 2 2 5 5 4 4 3 2 4 3 8.3 8.3 8.3 8.3 
q5 10 10 10 10 10 10 8 8 5 3 6 5 8.3 8.3 8.3 8.3 
A 
q1 299 27 27 27 679 41 725 45 282 771 325 168 17.0 12.0 17.0 8.7 
q2 94 50 50 50 1,772 1,431 1,783 1,456 853 1.2s 917 15s 33.5 33.7 33.2 32.3 
q3 104 104 104 104 4,754 4,468 4,751 4,467 2.5s 2.8s 2.5s 2m 49.9 50.0 46.3 43.2 
q4 456 224 224 224 6,740 3,159 6,838 3,410 3.4s 3.6s 3.4s 1.3m 93.9 111.9 97.5 50.2 
q5 624 624 624 624 69,44932,92270,48638,902 43.4s 44.5s 43.2s † 865.1 859.7863.9 † 
P5 
q1 6 6 6 6 14 14 13 13 2 2 3 2 4.2 4.2 4.2 4.2 
q2 10 10 10 10 77 25 80 47 9 9 11 15 8.6 8.6 8.6 8.6 
q3 13 13 13 13 400 60 413 208 61 52 53 303 11.4 11.4 11.4 14.95 
q4 15 15 15 15 2210 180 2273 936 400 391 375 11s 33.5 33.5 33.5 124.2 
q5 16 16 16 16 13085 725 13424 5188 3s 3.1s 3.3s † 208.6 208.4208.3 † 
SF 
q1 1 1 1 1 3 3 0 0 3 30 3 5 6.2 6.2 6.2 6.2 
q2 125 125 125 125 15 15 12 12 6 97 11 11 6.6 6.6 6.6 6.6 
q3 1,000 1,000 1,000 1,000 30 30 27 27 15 1.5s 23 28 9.1 6.6 9.1 9.1 
q4 8,000 8,000 8,000 8,000 60 60 57 57 82 83s 84 89 27.4 83.6 27.4 27.4 
q5 27,00027,00027,00027,000 39 39 33 33 472 † 427 415 121.5 384.5121.5 † 
CLQ 
q1 38 38 38 38 38 38 57 57 8 41 28 45 4.6 5.1 5.1 5.1 
q2 38 38 38 38 39 39 56 56 15 41 31 60 4.7 5.3 5.3 5.3 
q3 152 152 152 152 44 44 59 59 17 1.3s 38 56 5.5 17.7 6.0 6.0 
q4 5,776 5,776 5,776 5,776 82 82 112 112 317 † 41 426 87.1 † 88.1 88.1
Rewriting aAndrOcpthimiiztaetiocn tfour Ornetological Databases 0:33 
Query 
Manager 
Rewriting Engine 
q 
Qq Constraints 
Violations Answer 
D 
Q 
CG(Σ ) 
Σ 
SQL Rewriter 
Q⊥ 
SQq SQ SQ⊥ 
Q ⌃ 
q1 q2 qk 
FO 
Rewriter 
FO 
Rewriter 
... Cache 
FO 
Rewriter 
Manager 
Query 
Decomposer 
Q1 Q2 Qk 
Unfolder 
ρ 
Qq 
q Σ 
CG(Σ ) 
Prototype implementation 
IRIS+/- 
https://bitbucket.org/giorsi/nyaya 
Q⌃
Rewriting aAndrOcpthimiiztaetiocn tfour Ornetological Databases 0:33 
Query 
Manager 
Rewriting Engine 
q 
Qq Constraints 
Violations Answer 
D 
Q 
CG(Σ ) 
Σ 
SQL Rewriter 
Q⊥ 
SQq SQ SQ⊥ 
Q ⌃ 
q1 q2 qk 
FO 
Rewriter 
FO 
Rewriter 
... Cache 
FO 
Rewriter 
Manager 
Query 
Decomposer 
Q1 Q2 Qk 
Unfolder 
ρ 
Qq 
q Σ 
CG(Σ ) 
Prototype implementation 
IRIS+/- 
https://bitbucket.org/giorsi/nyaya 
Q⌃
Caching 
App–8 G. Gottlob et al. 
Classical caching mechanisms can be applied during rewriting 
Table VIII. The impact of caching (per-query averages). 
V S U A P5 SF CLQ 
Factorization 0 1 0 37k 9k 0 0 
Same invocation (%) 0 0 0 0 0 0 0 
Distinct input 0 1 0 37k 9k 0 0 
Atom coverage 12 18 12 642k 202k 10 N/A 
Same invocation (%) 0 12 11.2 86 63.4 0 N/A 
Distinct input 12 2 9 3k 2k 10 N/A 
Homomorphism check 447 12 8 863k 145 351 1.4k 
Same invocation (%) 0 0 0 0 0 0 0 
Distinct input 447 12 8 863k 145 351 1.4k 
MGU computation 457 97 25 294k 93k 500k 24k 
Same invocation (%) 72.3 50.4 34.8 98.2 79.6 77.6 98.3 
Distinct input 73 27 13 384 6k 92 345 
Canonical renaming 5k 249 558 4.6M 63k 17k 6k 
Same invocation (%) 90.6 66.8 64.6 97.2 78.8 63.4 75.6 
Distinct input 372 69 106 76k 15k 8k 2k 
Bottom line: caching canonical renamings and MGUs does most of the job. 
that eliminatek+1(q, S1,Σ)eliminatek+1(q, S2,Σ) but they have the same cardinality. 
Now, consider an atom ̸= b ∈ body(q). If ak ≺q 
b, since q 
, by transitivity of 
Σ ak+1 ≺Σ ak≺q 
Σ, we get that ak+1 ≺q 
Σ b. Conversely, if ak+1 ≺q 
Σ b, since ak ≺q 
Σ ak+1, we get that 
Caching ak ≺q 
b. Hence, factorizations ak ≺q 
b iff and ak+homomorphic ≺q 
checks is useless, i.e., our 
Σ Σ 1 algorithm explores the rewriting space efficiently. 
Σ b, or, equivalently, ak ∈ cover(b) iff ak+1 ∈ cover(b). 
Observe that, after the (k + 1)-th application of the for-loop, for each i ∈ {k +2, . . . ,n}, 
either cover(S1[i]) = cover(S2[i]), or cover(S1[i]) cover(S2[i]) = {ak+1} and cover(S2[i])  cover(S1[i]) = {ak}. Consequently, |eliminate(q, S1,Σ)| = |eliminate(q, S2,Σ)|.
What is left to do… 
Parallelization 
Recursive query decomposition 
Ontology decomposition 
Execution 
Map-reducing queries and rewritings 
Exploiting storage constraints [de Virgilio et Al. CIKM ’11, Rodriguez-Muro 
et Al. DL’14] 
Static analysis 
Analyze the theory to determine which optimisations to apply
Full set of experiments and code at: https://bitbucket.org/giorsi/nyaya

More Related Content

Viewers also liked

OPAL: automated form understanding for the deep web - WWW 2012
OPAL: automated form understanding for the deep web - WWW 2012OPAL: automated form understanding for the deep web - WWW 2012
OPAL: automated form understanding for the deep web - WWW 2012
Giorgio Orsi
 
Deos 2014 - Welcome
Deos 2014 - WelcomeDeos 2014 - Welcome
Deos 2014 - Welcome
Giorgio Orsi
 
Datalog and its Extensions for Semantic Web Databases
Datalog and its Extensions for Semantic Web DatabasesDatalog and its Extensions for Semantic Web Databases
Datalog and its Extensions for Semantic Web DatabasesGiorgio Orsi
 
Querying UML Class Diagrams - FoSSaCS 2012
Querying UML Class Diagrams - FoSSaCS 2012Querying UML Class Diagrams - FoSSaCS 2012
Querying UML Class Diagrams - FoSSaCS 2012
Giorgio Orsi
 
OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)
OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)
OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)
Giorgio Orsi
 
DIADEM WWW 2012
DIADEM WWW 2012DIADEM WWW 2012
DIADEM WWW 2012
Giorgio Orsi
 
Joint Repairs for Web Wrappers
Joint Repairs for Web WrappersJoint Repairs for Web Wrappers
Joint Repairs for Web Wrappers
Giorgio Orsi
 

Viewers also liked (8)

OPAL: automated form understanding for the deep web - WWW 2012
OPAL: automated form understanding for the deep web - WWW 2012OPAL: automated form understanding for the deep web - WWW 2012
OPAL: automated form understanding for the deep web - WWW 2012
 
Deos 2014 - Welcome
Deos 2014 - WelcomeDeos 2014 - Welcome
Deos 2014 - Welcome
 
Datalog and its Extensions for Semantic Web Databases
Datalog and its Extensions for Semantic Web DatabasesDatalog and its Extensions for Semantic Web Databases
Datalog and its Extensions for Semantic Web Databases
 
Querying UML Class Diagrams - FoSSaCS 2012
Querying UML Class Diagrams - FoSSaCS 2012Querying UML Class Diagrams - FoSSaCS 2012
Querying UML Class Diagrams - FoSSaCS 2012
 
OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)
OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)
OPAL: a passe-partout for web forms - WWW 2012 (Demonstration)
 
Oxpath vldb
Oxpath vldbOxpath vldb
Oxpath vldb
 
DIADEM WWW 2012
DIADEM WWW 2012DIADEM WWW 2012
DIADEM WWW 2012
 
Joint Repairs for Web Wrappers
Joint Repairs for Web WrappersJoint Repairs for Web Wrappers
Joint Repairs for Web Wrappers
 

Similar to Query Rewriting and Optimization for Ontological Databases

LAC2013 UNIT preTESTs!
LAC2013 UNIT preTESTs!LAC2013 UNIT preTESTs!
LAC2013 UNIT preTESTs!A Jorge Garcia
 
ABC workshop: 17w5025
ABC workshop: 17w5025ABC workshop: 17w5025
ABC workshop: 17w5025
Christian Robert
 
20 prolog5
20 prolog520 prolog5
20 prolog5
choconyeuquy
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
Rohit Garg
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
Programming Homework Help
 
Pi s7-2016-p(gate2016.info)
Pi s7-2016-p(gate2016.info)Pi s7-2016-p(gate2016.info)
Pi s7-2016-p(gate2016.info)
DrRojaAbrahamRaju
 
And or graph problem reduction using predicate logic
And or graph problem reduction using predicate logicAnd or graph problem reduction using predicate logic
And or graph problem reduction using predicate logic
Mohanlal Sukhadia University (MLSU)
 
09 logic programming
09 logic programming09 logic programming
09 logic programming
saru40
 
[ABDO] Logic As A Database Language
[ABDO] Logic As A Database Language[ABDO] Logic As A Database Language
[ABDO] Logic As A Database LanguageCarles Farré
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Stavros Vassos
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
mihir jain
 
Soln dc05
Soln dc05Soln dc05
Soln dc05
khalil_superior
 
Developing Expert Voices
Developing Expert VoicesDeveloping Expert Voices
Developing Expert VoicesbL__ah
 
GATE-ec-question-Paper-2018.pdf-82.pdf
GATE-ec-question-Paper-2018.pdf-82.pdfGATE-ec-question-Paper-2018.pdf-82.pdf
GATE-ec-question-Paper-2018.pdf-82.pdf
JAYMINKUMARPATEL1
 
Mathematical sciences-paper-ii
Mathematical sciences-paper-iiMathematical sciences-paper-ii
Mathematical sciences-paper-iiknowledgesociety
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere Mortals
Bertram Ludäscher
 

Similar to Query Rewriting and Optimization for Ontological Databases (20)

LAC2013 UNIT preTESTs!
LAC2013 UNIT preTESTs!LAC2013 UNIT preTESTs!
LAC2013 UNIT preTESTs!
 
ABC workshop: 17w5025
ABC workshop: 17w5025ABC workshop: 17w5025
ABC workshop: 17w5025
 
20 prolog5
20 prolog520 prolog5
20 prolog5
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Pi s7-2016-p(gate2016.info)
Pi s7-2016-p(gate2016.info)Pi s7-2016-p(gate2016.info)
Pi s7-2016-p(gate2016.info)
 
And or graph problem reduction using predicate logic
And or graph problem reduction using predicate logicAnd or graph problem reduction using predicate logic
And or graph problem reduction using predicate logic
 
09 logic programming
09 logic programming09 logic programming
09 logic programming
 
[ABDO] Logic As A Database Language
[ABDO] Logic As A Database Language[ABDO] Logic As A Database Language
[ABDO] Logic As A Database Language
 
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
Intro to AI STRIPS Planning & Applications in Video-games Lecture3-Part1
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
 
Soln dc05
Soln dc05Soln dc05
Soln dc05
 
DEV
DEVDEV
DEV
 
Developing Expert Voices
Developing Expert VoicesDeveloping Expert Voices
Developing Expert Voices
 
GATE-ec-question-Paper-2018.pdf-82.pdf
GATE-ec-question-Paper-2018.pdf-82.pdfGATE-ec-question-Paper-2018.pdf-82.pdf
GATE-ec-question-Paper-2018.pdf-82.pdf
 
Mathematical sciences-paper-ii
Mathematical sciences-paper-iiMathematical sciences-paper-ii
Mathematical sciences-paper-ii
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere Mortals
 
Pl vol1
Pl vol1Pl vol1
Pl vol1
 
Gottlob ICDE 2011
Gottlob ICDE 2011Gottlob ICDE 2011
Gottlob ICDE 2011
 

More from Giorgio Orsi

Web Data Extraction: A Crash Course
Web Data Extraction: A Crash CourseWeb Data Extraction: A Crash Course
Web Data Extraction: A Crash Course
Giorgio Orsi
 
Fairhair.ai – alan turing institute june '17 (public)
Fairhair.ai – alan turing institute june '17 (public)Fairhair.ai – alan turing institute june '17 (public)
Fairhair.ai – alan turing institute june '17 (public)
Giorgio Orsi
 
SAE: Structured Aspect Extraction
SAE: Structured Aspect ExtractionSAE: Structured Aspect Extraction
SAE: Structured Aspect Extraction
Giorgio Orsi
 
wadar_poster_final
wadar_poster_finalwadar_poster_final
wadar_poster_finalGiorgio Orsi
 
ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014
ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014
ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014
Giorgio Orsi
 
Heuristic Ranking in Tightly Coupled Probabilistic Description Logics
Heuristic Ranking in Tightly Coupled Probabilistic Description LogicsHeuristic Ranking in Tightly Coupled Probabilistic Description Logics
Heuristic Ranking in Tightly Coupled Probabilistic Description Logics
Giorgio Orsi
 
AMBER WWW 2012 Poster
AMBER WWW 2012 PosterAMBER WWW 2012 Poster
AMBER WWW 2012 PosterGiorgio Orsi
 
AMBER WWW 2012 (Demonstration)
AMBER WWW 2012 (Demonstration)AMBER WWW 2012 (Demonstration)
AMBER WWW 2012 (Demonstration)
Giorgio Orsi
 
Nyaya: Semantic data markets: a flexible environment for knowledge management...
Nyaya: Semantic data markets: a flexible environment for knowledge management...Nyaya: Semantic data markets: a flexible environment for knowledge management...
Nyaya: Semantic data markets: a flexible environment for knowledge management...
Giorgio Orsi
 
The Diadem Ontology
The Diadem OntologyThe Diadem Ontology
The Diadem OntologyGiorgio Orsi
 
AMBER presentation
AMBER presentationAMBER presentation
AMBER presentationGiorgio Orsi
 
Invited Iceis Tanca Orsi
Invited Iceis Tanca OrsiInvited Iceis Tanca Orsi
Invited Iceis Tanca OrsiGiorgio Orsi
 
X Som Graduation Presentation
X Som   Graduation PresentationX Som   Graduation Presentation
X Som Graduation PresentationGiorgio Orsi
 
Web Data Extraction Como2010
Web Data Extraction Como2010Web Data Extraction Como2010
Web Data Extraction Como2010Giorgio Orsi
 

More from Giorgio Orsi (20)

Web Data Extraction: A Crash Course
Web Data Extraction: A Crash CourseWeb Data Extraction: A Crash Course
Web Data Extraction: A Crash Course
 
Fairhair.ai – alan turing institute june '17 (public)
Fairhair.ai – alan turing institute june '17 (public)Fairhair.ai – alan turing institute june '17 (public)
Fairhair.ai – alan turing institute june '17 (public)
 
SAE: Structured Aspect Extraction
SAE: Structured Aspect ExtractionSAE: Structured Aspect Extraction
SAE: Structured Aspect Extraction
 
diadem-vldb-2015
diadem-vldb-2015diadem-vldb-2015
diadem-vldb-2015
 
wadar_poster_final
wadar_poster_finalwadar_poster_final
wadar_poster_final
 
ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014
ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014
ROSeAnn: Reconciling Opinions of Semantic Annotators VLDB 2014
 
Perv a ds-rr13
Perv a ds-rr13Perv a ds-rr13
Perv a ds-rr13
 
Heuristic Ranking in Tightly Coupled Probabilistic Description Logics
Heuristic Ranking in Tightly Coupled Probabilistic Description LogicsHeuristic Ranking in Tightly Coupled Probabilistic Description Logics
Heuristic Ranking in Tightly Coupled Probabilistic Description Logics
 
AMBER WWW 2012 Poster
AMBER WWW 2012 PosterAMBER WWW 2012 Poster
AMBER WWW 2012 Poster
 
AMBER WWW 2012 (Demonstration)
AMBER WWW 2012 (Demonstration)AMBER WWW 2012 (Demonstration)
AMBER WWW 2012 (Demonstration)
 
Nyaya: Semantic data markets: a flexible environment for knowledge management...
Nyaya: Semantic data markets: a flexible environment for knowledge management...Nyaya: Semantic data markets: a flexible environment for knowledge management...
Nyaya: Semantic data markets: a flexible environment for knowledge management...
 
Table Recognition
Table RecognitionTable Recognition
Table Recognition
 
The Diadem Ontology
The Diadem OntologyThe Diadem Ontology
The Diadem Ontology
 
Diadem 1.0
Diadem 1.0Diadem 1.0
Diadem 1.0
 
OPAL Presentation
OPAL PresentationOPAL Presentation
OPAL Presentation
 
AMBER presentation
AMBER presentationAMBER presentation
AMBER presentation
 
Orsi PersDB11
Orsi PersDB11Orsi PersDB11
Orsi PersDB11
 
Invited Iceis Tanca Orsi
Invited Iceis Tanca OrsiInvited Iceis Tanca Orsi
Invited Iceis Tanca Orsi
 
X Som Graduation Presentation
X Som   Graduation PresentationX Som   Graduation Presentation
X Som Graduation Presentation
 
Web Data Extraction Como2010
Web Data Extraction Como2010Web Data Extraction Como2010
Web Data Extraction Como2010
 

Recently uploaded

The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
u86oixdj
 
Nanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdfNanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdf
eddie19851
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
mzpolocfi
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
slg6lamcq
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Subhajit Sahu
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 

Recently uploaded (20)

The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
 
Nanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdfNanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdf
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
一比一原版(Dalhousie毕业证书)达尔豪斯大学毕业证如何办理
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 

Query Rewriting and Optimization for Ontological Databases

  • 1. Query Rewriting and Optimization for Ontological Databases! Georg Gottlob, Giorgio Orsi, and Andreas Pieris! name.surname@cs.ox.ac.uk! ! ! Department of Computer Science! Oxford University! ! Dagstuhl 2014 References: !Gottlob et Al. Query Rewriting and Optimization for Ontological Databases. ! ! ! ACM TODS 2014.
  • 2. Ontological query answering query theory ? Q ⌃ D database
  • 3. Ontological query answering query theory ? Q ⌃ D database chasing is an option but we would like to use a DBMS to answer the query.
  • 4. Our setting: The constraint language: tuple-generating dependencies (TGDs) 8X8Y '(X,Y) ! 9Z (X,Z) 8X '(X) ! Xi = Xj equality-generating dependencies (EGDs) 8X '(X)!? negative constraints (NCs) Query language: Q : 9Y'(X,Y) conjunctive queries (CQs) EGDs and NCs that are well-behaved can be checked beforehand and then ignored during the rewriting (i.e., non conflicting, separable).
  • 5. FO-rewritability Very well known in the DL area [Calvanese et Al. JAR’07] Q ⌃ Q⌃ rewrite using D 8D : chase(D,⌃) |= Q $ D |= Q⌃
  • 6. Concrete FO-rewritable classes Linear TGDs one body atom (generalize IDs) [Cali et Al. PODS’09] 8X8Y8Z r(X,Y) ! 9Z (X,Z) Sticky TGDs 0:12 t(X,Y,Z) → ∃W s(Y,W) [Cali et Al. VLDB’10] Join variables stick to the inferred atoms Abstract classes Finite unification sets FUS [Baget et Al. AIJ’11] r(X,Y),p(Y,Z) → ∃W t(X,Y,W) r(X,Y),p(Y,Z) → ∃W t(X,Y,W) t(X,Y,Z) → ∃W s(X,W) × √ (a) Fig. 3. Sticky property and propagation
  • 7. Bounded derivation depth property [Cali et Al. PODS’09] BDDP ) (positive) first-order rewritability Q D chase(D,Σ) depth depends on Q and Σ but not on D
  • 8. BDDP rewriting 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A, db,B) [Cali et Al. PODS’09]: enumerate all the possible ancestor databases such that the input query maps to their chase.
  • 9. BDDP rewriting 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A, db,B) [Cali et Al. PODS’09]: enumerate all the possible ancestor databases such that the input query maps to their chase. D hasCollaborator(a, db, b) D⌃ hasCollaborator (a, db, b) collaborator (a) Q maps! constants fromQ frozen nulls Q1 : 9AhasCollaborator(A, db,B)
  • 10. BDDP rewriting 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A, db,B) [Cali et Al. PODS’09]: enumerate all the possible ancestor databases such that the input query maps to their chase. D D … hasCollaborator(a, db, b) Q maps! inArea(a, db) project(a) inArea(a, db) D⌃ project(a) Q1 : 9AhasCollaborator(A, db,B) Q maps! Q2 : project(A), inArea(A, db) D⌃ hasCollaborator (a, db, b) collaborator (a) hasCollaborator(z0, db, a) collaborator (z0) constants fromQ frozen nulls
  • 11. BDDP rewriting 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A, db,B) [Cali et Al. PODS’09]: enumerate all the possible ancestor databases such that the input query maps to their chase. D D … hasCollaborator(a, db, b) Q maps! inArea(a, db) project(a) inArea(a, db) D⌃ project(a) Q1 : 9AhasCollaborator(A, db,B) Q maps! Q2 : project(A), inArea(A, db) Q⌃ : Q1 _ Q2 _ . . . D⌃ hasCollaborator (a, db, b) collaborator (a) hasCollaborator(z0, db, a) collaborator (z0) constants fromQ frozen nulls
  • 12. Backward resolution [Calvanese et Al. JAR’07, Cali et Al. AMW’10]: Construct a (perfect) rewriting via backward resolution. 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A,B,C), collaborator (A)
  • 13. Backward resolution [Calvanese et Al. JAR’07, Cali et Al. AMW’10]: Construct a (perfect) rewriting via backward resolution. 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A,B,C), collaborator (A) Step 1: rewriting Q : 9A hasCollaborator(A,B,C), collaborator (A) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X)
  • 14. Backward resolution [Calvanese et Al. JAR’07, Cali et Al. AMW’10]: Construct a (perfect) rewriting via backward resolution. 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Step 1: rewriting Q : 9A hasCollaborator(A,B,C), collaborator (A) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) μ : {X7! A} Q : 9A hasCollaborator(A,B,C), collaborator (A)
  • 15. Backward resolution [Calvanese et Al. JAR’07, Cali et Al. AMW’10]: Construct a (perfect) rewriting via backward resolution. 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Q : 9A hasCollaborator(A,B,C), collaborator (A) Step 1: rewriting Q : 9A hasCollaborator(A,B,C), collaborator (A) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) μ : {X7! A} Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1)
  • 16. Careful with MGUs! 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) unsound rewriting Q : hasCollaborator(a, b,C) μ : {Z7! a, Y7! b,X7! C} Q0 : project(C), inArea(C, b)
  • 17. Careful with MGUs! 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) unsound rewriting Q : hasCollaborator(a, b,C) μ : {Z7! a, Y7! b,X7! C} Q0 : project(C), inArea(C, b) D project(a) inArea(a, b) D⌃ project(a) inArea(a, b) hasCollaborator(z0, b, a) Q does not map here but Q0 does! Applicability: prevent MGUs which unify existential variables with join variables (included self) and constants.
  • 18. Backward resolution 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Step 2: minimization Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1)
  • 19. Backward resolution 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Step 2: minimization Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1) stuck! Applicability prevents us from rewriting. Rewriting is still incomplete.
  • 20. Backward resolution 1 : project(X), inArea(X, Y ) ! 9Z hasCollaborator(Z, Y ,X) 2 : hasCollaborator(X, Y ,Z) ! collaborator(X) Step 2: minimization Q0 : 9A9V09V1 hasCollaborator(A,B,C), hasCollaborator(A, V0, V1) stuck! Applicability prevents us from rewriting. Rewriting is still incomplete. subquery μ : {V07! B, V17! C} (different from Chandra Merlin) Q00 : 9A hasCollaborator(A,B,C) now we can rewrite with 2 Loop until no more steps are applicable. In general, this process might not terminate, each class of TGDs might require a different stop condition (exploit linearity and stickiness).
  • 21. Opt. 1: Factorization Exhaustive minimisations are not necessary. Only those which free shared existential variables are useful reductions : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D)
  • 22. Opt. 1: Factorization Exhaustive minimisations are not necessary. Only those which free shared existential variables are useful reductions : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} Q0 : 9B9D r(C,B), r(B,D) B is still shared!
  • 23. Opt. 1: Factorization Exhaustive minimisations are not necessary. Only those which free shared existential variables are useful reductions : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} Q0 : 9B9D r(C,B), r(B,D) B is still shared! Piece unifiers, factorizations [Baget et Al. ICCS’96, Gottlob et Al. ICDE ’11]. : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) Q1 : 9B9C t(a,A,C), t(B, a,C)
  • 24. Opt. 1: Factorization Exhaustive minimisations are not necessary. : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} Q0 : 9B9D r(C,B), r(B,D) B is still shared! Backward resolution still complete if we perform only those that free shared existential variables [Baget et Al. ICCS’96] Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) Q1 : 9B9C t(a,A,C), t(B, a,C)
  • 25. Opt. 1: Factorization Exhaustive minimisations are not necessary. : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} Q0 : 9B9D r(C,B), r(B,D) B is still shared! Backward resolution still complete if we perform only those that free shared existential variables [Baget et Al. ICCS’96] Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) Q1 : 9B9C t(a,A,C), t(B, a,C) Q2 : 9B9C9E s(C), t(A,B,C), t(A,E,C)
  • 26. Opt. 1: Factorization Exhaustive minimisations are not necessary. : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} Q0 : 9B9D r(C,B), r(B,D) B is still shared! Backward resolution still complete if we perform only those that free shared existential variables [Baget et Al. ICCS’96] Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) Q1 : 9B9C t(a,A,C), t(B, a,C) Q2 : 9B9C9E s(C), t(A,B,C), t(A,E,C) Q3 : 9B9C t(A,B,C), t(A,C,C)
  • 27. Opt. 1: Factorization Exhaustive minimisations are not necessary. : s(X) ! 9Y r(X, Y ) Q : 9B9C9D r(A,B), r(C,B), r(B,D) μ : {A7! C} Q0 : 9B9D r(C,B), r(B,D) B is still shared! Backward resolution still complete if we perform only those that free shared existential variables [Baget et Al. ICCS’96] Application in query rewriting: [Gottlob et Al. ICDE ’11, Konig et Al. RR’12]. : s(X), r(X, Y ) ! 9Z t(X, Y ,Z) Q1 : 9B9C t(a,A,C), t(B, a,C) Q2 : 9B9C9E s(C), t(A,B,C), t(A,E,C) Q3 : 9B9C t(A,B,C), t(A,C,C)
  • 28. Opt. 2: Atom coverage Queries can be reduced during rewriting. We eliminate rewriting steps! : t(X, Y ) ! 9Z r(X, Y ,Z) Q : 9B9C t(A,B), r(A,B,C), s(A,B,B)
  • 29. Opt. 2: Atom coverage Queries can be reduced during rewriting. We eliminate rewriting steps! : t(X, Y ) ! 9Z r(X, Y ,Z) Q : 9B9C t(A,B), r(A,B,C), s(A,B,B) r(A,B,C) Under the atom can be eliminated, obtaining an (equivalent) query Q0 : 9B t(A,B), s(A,B,B) Chase and Backchase [Deutsch et Al. PODS’08, Maier VLDBJ’14] But… chase is of exponential size and has to be constructed for (worst-case) exponentially many queries.
  • 30. Opt. 2: Atom coverage For linear TGDs (one body atom), it amounts to reachability in a graph (but we lose some implications…). : t(X, Y ) ! 9Z r(X, Y ,Z) Precompute a propagation graph t[1] t[2] r[1] r[2] r[3] Roughly: check that it is possible to propagate terms from the covering atom to the covered one using the same sequence of TGDs The elimination strategy is unique w.r.t. the size (number of atoms) of the resulting query. Q : 9B9C t(A,B), r(A,B,C), s(A,B,B)
  • 31. Opt. 2: Atom coverage Instead of testing reachability we can use a cover graph Q(ui.eery., Rthewe rtitriangnsanitdivOe pctilmoiszuatrieon ofof rthOen tpolroogpicaalgDaatitoabna gsersaph). 0:41 Table IV. Propagation and cover graphs. Size (#nodes,#edges) LP Time (ms) Memory P-GRAPH C-GRAPH C-GRAPHP-GRAPHC-GRAPHP-GRAPHC-GRAPH V (214,445) (214,1194) 7 4 158 190Kb 4.7Mb S (41,103) (41,405) 8 1 120 45Kb 4,4Mb U (86,189) (86,416) 6 1 37 81Kb 4.4Mb A (135,319) (135,1133) 10 43 708 154Kb 4.7Mb P5 (15,32) (15,43) 3 0 1 14Kb 4.3Mb SF (100,195) (100,1,050) 19 1 346 84Kb 4.8Mb CLQ (11,143) N/A N/A 2 N/A 39Kb N/A Differently from the query graph, the propagation and the cover graph depend only on the input ontology and not on the input query. Table IV reports the characteristics of The both cover the propagation graph becomes graph (unmanageable P-GRAPH) and the for cover large graph ontologies (C-GRAPH) (Galen constructed lite). for each ontology. In particular, we report on the size of the two structures in terms of Either the number pay the of reachability nodes and edges, price on the the time propagation necessary to graph construct (use a them, graph and DB). their memory footprint. For the cover graph, we also report the length of the longest label on an edge (LP), corresponding to the longest tight sequence of TGDs that we have to consider during the computation of cover sets. Since query elimination can be applied
  • 32. ImQuperyaRecwrtitin goandfO pmtimizaitnionifomr OntiolzogiacaltDaitoabanses 0:37 Table I. The impact of query elimination on the rewriting. Size #Atoms #Joins Explored Generated Time (ms) Memory (MB) BASE QE BASE QE BASE QE BASE QE BASE QE BASE QE BASE QE V q1 15 15 15 15 0 0 15 15 14 14 9 9 4.3 4.3 q2 10 10 30 30 30 30 10 10 9 9 7 7 4.3 6.3 q3 72 72 216 216 144 144 72 72 71 71 44 45 4.7 6.7 q4 185 185 555 555 370 370 185 185 184 184 111 115 5.4 7.4 q5 30 30 210 210 270 270 30 30 29 29 26 28 4.6 6.6 S q1 6 6 6 6 0 0 6 6 7 7 2 2 4.1 4.1 q2 160 2 480 2 320 0 160 2 244 1 43 2 5.9 8.2 q3 504 4 2,520 8 2,520 4 504 4 823 3 198 8 16.8 8.2 q4 960 4 4,800 8 4,800 4 960 4 1,445 3 363 2 25.3 8.2 q5 3,024 8 21,168 24 27,216 24 3,024 8 4,892 7 1.7s 3 12.6 8.3 U q1 2 2 4 4 2 2 5 5 4 4 3 3 4.1 6.2 q2 148 1 444 1 296 0 240 1 250 0 73 1 5.8 4.1 q3 224 4 1,344 16 2,016 20 1,008 12 1,007 11 432 7 18.5 8.3 q4 1,628 2 4,884 2 1,628 0 5,000 5 6,094 4 1.6s 3 54.1 8.2 q5 3,009 10 12,036 20 18,054 20 8,154 25 11,970 24 3.2s 8 119.2 8.4 A q1 402 299 779 573 377 274 782 679 847 725 818 729 7.9 17.0 q2 103 94 256 238 153 144 1,784 1,772 1,783 1,783 1.1s 1.2s 19.1 33.4 q3 104 104 520 520 520 520 4,752 4,752 4,751 4,751 3.2s 3.5s 62.7 97.5 q4 492 456 1,288 1,216 796 760 7,110 6,740 7,110 6,838 3.8s 3.5s 67.8 65.8 q5 624 624 3,120 3,120 3,120 3,120 76,12269,44876,12170,457 52.3s 49.8s 1.1G 981.5 P5 q1 6 6 6 6 0 0 14 14 13 13 1 2 4.1 4.1 q2 10 10 16 16 6 6 77 77 76 80 55 8 4.5 8.6 q3 13 13 29 29 16 16 410 400 409 413 57 52 7.4 11.4 q4 15 15 44 44 29 29 2,275 2,210 2,274 2,273 368 403 30.3 33.5 q5 16 16 60 60 44 44 13,52213,08513,52113,424 3.2s 3.2s 211.7 208.3 SF q1 1 1 3 3 2 2 1 1 0 0 1 1 0.053 2.1 q2 125 125 375 375 250 250 125 125 124 124 30 33 5.1 7.1 q3 1,000 1,000 3,000 3,000 2,000 2,000 1,000 1,000 999 999 227 237 12.6 14.7 q4 8,000 8,000 24,000 24,000 16,000 16,000 8,000 8,000 7,999 7,999 2s 2.2s 77.2 77.0 q5 27,00027,000162,000162,000108,000108,00027,00027,00026,99926,999 12.4s 12.4s 560.7 561.6
  • 33. Parallelization Q splitter Q1 Q2 … Qn merger Q⌃
  • 34. Parallelization The rewriting can be computed in parallel by decomposing the query 1 : p(X, Y ), s(Y ,Z) ! 9W t(Y ,X,W) 2 : t(X, Y ,Z) ! 9W p(W,Z) 1 : {t[3], p[2]} 2 : {p[1], t[2]} Q : q(A,D) p(D,B), t(A,B,C), p(E,C) Atoms that do not join on existential positions can be rewritten independently. Q1 : q1(A,B) t(A,B,C), p(E,C) Q2 : q2(D,B) p(D,B) Bind in the head of the component distinguished and cross-component join variables. reconciliation rule. Q⇢ : q(A,D) q1(A,B), q2(D,B) Then, unfold using the reconciliation rule.
  • 35. Impa0:38ct of parallelization G. Gottlob et al. Table II. The impact of parallelization on the rewriting. Size Explored Generated Time (ms) Memory (MB) Comp BASE PARA BASE PARA BASE PARA BASE PARA Rew Split Unfold BASE PARA V q1 1 15 15 15 15 14 14 9 14 14 0 0 4.3 4.3 q2 3 10 10 10 12 9 9 7 4 3 1 0 6.3 6.4 q3 3 72 72 72 28 71 25 45 25 24 1 2 6.7 6.7 q4 3 185 185 185 43 184 40 115 26 26 0 3 7.5 7.4 q5 7 30 30 30 14 29 7 28 16 16 0 2 6.6 6.7 S q1 1 6 6 6 6 7 7 2 2 2 0 0 4.2 4.2 q2 1 2 2 2 2 1 1 2 2 1 0 0 8.2 8.2 q3 1 4 4 4 4 3 3 8 3 2 0 0 8.2 8.2 q4 2 4 4 4 4 3 2 2 3 2 0 0 8.2 8.2 q5 2 8 8 8 6 7 4 3 4 3 1 0 8.3 8.3 U q1 2 2 2 5 6 4 4 3 4 3 0 0 6.2 6.2 q2 1 1 1 1 1 0 0 1 1 1 0 0 4.1 4.1 q3 4 4 4 12 9 11 5 7 4 3 1 1 8.3 8.3 q4 1 2 2 5 5 4 4 3 3 2 0 0 8.2 8.2 q5 2 10 10 25 10 24 8 8 5 5 0 0 8.3 8.3 A q1 1 299 299 679 679 725 725 729 282 281 1 0 17.0 17.0 q2 1 94 94 1,772 1,772 1,783 1,783 1.2s 853 852 1 0 33.4 33.4 q3 3 104 104 4,752 4,754 4,751 4,751 3.5s 2.5s 2.5s 3 7 97.5 49.8 q4 1 456 456 6,740 6,740 6,838 6,838 3.5s 3.5s 3.5s 1 0 65.9 93.9 q5 2 624 624 69,448 69,449 70,457 70,486 49.8s 43.4s 43.4s 5 18 981.5 865.0 P5 q1 1 6 6 14 14 13 13 2 2 1 0 0 4.1 4.1 q2 1 10 10 77 77 80 80 8 9 8 0 0 8.6 8.6 q3 1 13 13 400 400 413 413 52 61 61 0 0 11.4 11.4 q4 1 15 15 2,210 2,210 2,273 2,273 403 400 399 1 0 33.5 33.5 q5 1 16 16 13,085 13,085 13,424 13,424 3.2s 3.1s 3.1s 0 0 208.2 208.6 SF q1 3 1 1 1 3 0 0 1 3 2 1 1 2.1 6.2 q2 3 125 125 125 15 124 12 33 6 5 0 1 7.1 6.6 q3 3 1,000 1,000 1,000 30 999 27 237 15 14 1 10 14.7 9.1 q4 3 8,000 8,000 8,000 60 7,999 57 2.2s 82 82 0 73 770.4 274.4 q5 6 27,000 27,000 27,000 39 26,999 33 12.4s 472 471 1 464 561.6 121.4 CLQ q1 1 38 38 38 38 57 57 102 8 8 0 0 4.6 4.6 q2 2 38 38 38 39 54 56 140 15 14 1 1 4.6 4.7 q3 4 152 152 152 44 223 59 864 17 17 0 6 7.5 5.5 q4 5 5,776 5,776 5,776 82 9,871 112 48.3s 317 316 1 304 287.4 87.08
  • 36. A note on subsumption check A classic optimization mechanism (but expensive) is subsumption check Q1 subsumes Q2 if there exists μ such that μ(body(Q1)) ✓ body(Q2) and μ(head(Q1)) = head(Q2) Remove the subsumed queries from the rewriting. Three modes: • TAIL, at the end of the rewriting procedure (guarantees minimality) • intra-rewriting (IREW), after each rewriting step (guarantees minimality) • Careful! the rewriting operator must be prunable [Konig et Al. SWJ ’14] • intra-decomposition (IDEC), like TAIL but for each component (parallel version)
  • 37. ImpaQcuetry Reowritfin g asnduOptbimizsatioun fomr OntoplogitcaliDoatanbase scheck 0:39 Table III. The impact of subsumption check on the rewriting. Size Explored Generated Time (ms) Memory (MB) BASE TAIL IDEC IREW BASE IREW BASE IREW BASE TAIL IDECIREWBASE TAIL IDECIREW V q1 15 15 15 15 15 15 14 14 14 12 13 10 4.3 4.3 4.3 4.3 q2 10 10 10 10 12 12 9 9 4 9 7 26 6.4 6.4 6.4 6.4 q3 72 72 72 72 28 28 25 25 25 28 15 24 6.6 6.6 6.6 6.6 q4 185 185 185 185 43 43 40 40 26 75 28 55 7.4 7.4 7.4 7.4 q5 30 30 30 30 14 14 7 7 16 12 11 14 6.7 6.7 6.7 6.7 S q1 6 6 6 6 6 6 7 7 2 2 3 3 4.2 4.2 4.2 4.2 q2 2 2 2 2 2 2 1 1 2 2 3 2 8.2 8.2 8.2 8.2 q3 4 4 4 4 4 4 3 3 3 3 3 2 8.3 8.3 8.3 8.3 q4 4 4 4 4 4 4 2 2 3 3 4 5 8.3 8.3 8.3 8.3 q5 8 8 8 8 6 6 4 4 4 3 6 5 8.3 8.3 8.3 8.3 U q1 2 2 2 2 6 6 4 4 4 4 6 5 6.2 6.2 6.2 6.2 q2 1 1 1 1 1 1 0 0 1 1 1 2 4.2 4.2 4.2 4.2 q3 4 4 4 4 9 9 5 5 4 4 3 5 8.3 8.3 8.3 8.3 q4 2 2 2 2 5 5 4 4 3 2 4 3 8.3 8.3 8.3 8.3 q5 10 10 10 10 10 10 8 8 5 3 6 5 8.3 8.3 8.3 8.3 A q1 299 27 27 27 679 41 725 45 282 771 325 168 17.0 12.0 17.0 8.7 q2 94 50 50 50 1,772 1,431 1,783 1,456 853 1.2s 917 15s 33.5 33.7 33.2 32.3 q3 104 104 104 104 4,754 4,468 4,751 4,467 2.5s 2.8s 2.5s 2m 49.9 50.0 46.3 43.2 q4 456 224 224 224 6,740 3,159 6,838 3,410 3.4s 3.6s 3.4s 1.3m 93.9 111.9 97.5 50.2 q5 624 624 624 624 69,44932,92270,48638,902 43.4s 44.5s 43.2s † 865.1 859.7863.9 † P5 q1 6 6 6 6 14 14 13 13 2 2 3 2 4.2 4.2 4.2 4.2 q2 10 10 10 10 77 25 80 47 9 9 11 15 8.6 8.6 8.6 8.6 q3 13 13 13 13 400 60 413 208 61 52 53 303 11.4 11.4 11.4 14.95 q4 15 15 15 15 2210 180 2273 936 400 391 375 11s 33.5 33.5 33.5 124.2 q5 16 16 16 16 13085 725 13424 5188 3s 3.1s 3.3s † 208.6 208.4208.3 † SF q1 1 1 1 1 3 3 0 0 3 30 3 5 6.2 6.2 6.2 6.2 q2 125 125 125 125 15 15 12 12 6 97 11 11 6.6 6.6 6.6 6.6 q3 1,000 1,000 1,000 1,000 30 30 27 27 15 1.5s 23 28 9.1 6.6 9.1 9.1 q4 8,000 8,000 8,000 8,000 60 60 57 57 82 83s 84 89 27.4 83.6 27.4 27.4 q5 27,00027,00027,00027,000 39 39 33 33 472 † 427 415 121.5 384.5121.5 † CLQ q1 38 38 38 38 38 38 57 57 8 41 28 45 4.6 5.1 5.1 5.1 q2 38 38 38 38 39 39 56 56 15 41 31 60 4.7 5.3 5.3 5.3 q3 152 152 152 152 44 44 59 59 17 1.3s 38 56 5.5 17.7 6.0 6.0 q4 5,776 5,776 5,776 5,776 82 82 112 112 317 † 41 426 87.1 † 88.1 88.1
  • 38. Rewriting aAndrOcpthimiiztaetiocn tfour Ornetological Databases 0:33 Query Manager Rewriting Engine q Qq Constraints Violations Answer D Q CG(Σ ) Σ SQL Rewriter Q⊥ SQq SQ SQ⊥ Q ⌃ q1 q2 qk FO Rewriter FO Rewriter ... Cache FO Rewriter Manager Query Decomposer Q1 Q2 Qk Unfolder ρ Qq q Σ CG(Σ ) Prototype implementation IRIS+/- https://bitbucket.org/giorsi/nyaya Q⌃
  • 39. Rewriting aAndrOcpthimiiztaetiocn tfour Ornetological Databases 0:33 Query Manager Rewriting Engine q Qq Constraints Violations Answer D Q CG(Σ ) Σ SQL Rewriter Q⊥ SQq SQ SQ⊥ Q ⌃ q1 q2 qk FO Rewriter FO Rewriter ... Cache FO Rewriter Manager Query Decomposer Q1 Q2 Qk Unfolder ρ Qq q Σ CG(Σ ) Prototype implementation IRIS+/- https://bitbucket.org/giorsi/nyaya Q⌃
  • 40. Caching App–8 G. Gottlob et al. Classical caching mechanisms can be applied during rewriting Table VIII. The impact of caching (per-query averages). V S U A P5 SF CLQ Factorization 0 1 0 37k 9k 0 0 Same invocation (%) 0 0 0 0 0 0 0 Distinct input 0 1 0 37k 9k 0 0 Atom coverage 12 18 12 642k 202k 10 N/A Same invocation (%) 0 12 11.2 86 63.4 0 N/A Distinct input 12 2 9 3k 2k 10 N/A Homomorphism check 447 12 8 863k 145 351 1.4k Same invocation (%) 0 0 0 0 0 0 0 Distinct input 447 12 8 863k 145 351 1.4k MGU computation 457 97 25 294k 93k 500k 24k Same invocation (%) 72.3 50.4 34.8 98.2 79.6 77.6 98.3 Distinct input 73 27 13 384 6k 92 345 Canonical renaming 5k 249 558 4.6M 63k 17k 6k Same invocation (%) 90.6 66.8 64.6 97.2 78.8 63.4 75.6 Distinct input 372 69 106 76k 15k 8k 2k Bottom line: caching canonical renamings and MGUs does most of the job. that eliminatek+1(q, S1,Σ)eliminatek+1(q, S2,Σ) but they have the same cardinality. Now, consider an atom ̸= b ∈ body(q). If ak ≺q b, since q , by transitivity of Σ ak+1 ≺Σ ak≺q Σ, we get that ak+1 ≺q Σ b. Conversely, if ak+1 ≺q Σ b, since ak ≺q Σ ak+1, we get that Caching ak ≺q b. Hence, factorizations ak ≺q b iff and ak+homomorphic ≺q checks is useless, i.e., our Σ Σ 1 algorithm explores the rewriting space efficiently. Σ b, or, equivalently, ak ∈ cover(b) iff ak+1 ∈ cover(b). Observe that, after the (k + 1)-th application of the for-loop, for each i ∈ {k +2, . . . ,n}, either cover(S1[i]) = cover(S2[i]), or cover(S1[i]) cover(S2[i]) = {ak+1} and cover(S2[i]) cover(S1[i]) = {ak}. Consequently, |eliminate(q, S1,Σ)| = |eliminate(q, S2,Σ)|.
  • 41. What is left to do… Parallelization Recursive query decomposition Ontology decomposition Execution Map-reducing queries and rewritings Exploiting storage constraints [de Virgilio et Al. CIKM ’11, Rodriguez-Muro et Al. DL’14] Static analysis Analyze the theory to determine which optimisations to apply
  • 42. Full set of experiments and code at: https://bitbucket.org/giorsi/nyaya