# 2007, M. Spiekermann # # A SECONDO-Script which creates synthesized data used for # experiments with correlated predicates let ten = [const rel(tuple([A: int, B: int, C: int, D: int])) value ( (0 1 2 3) (1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7) (5 6 7 8) (6 7 8 9) (7 8 9 0) (8 9 0 1) (9 0 1 2) )]; #create table thousand # as select (A.a) * 100 + (B.a) * 10 + C.a as a # from ten as A, ten as B, ten as C order by a asc; # let thousand = ten feed {A} ten feed {B} ten feed {C} product product extend[No: (.A_A * 100) + (.A_B * 10) + .A_C] project[No] sortby[No asc] consume; # #-- Create two objects with one million tuples #create table m1 # as select (T.a % 1000) as a, ((T.a + 1) % 1000) as b, # ((T.a + 2) % 1000) as c, ((T.a + 3) % 1000) as d # from thousand, thousand as T; let m1 = thousand feed {R} thousand feed {T} product extend[A: .No_T mod 1000] extend[B: (.No_T + 1) mod 1000] extend[C: (.No_T + 2) mod 1000] extend[D: (.No_T + 3) mod 1000] project[A, B, C, D] consume; let m2 = m1; let m1_A = m1 createbtree[A]; # Queries: # sql select count(*) from [m1 as r, m2 as s] where [r:a = s:a, s:a=0, s:b=1] # # Nested Loop (9.43 s) # query m1_A m1 exactmatch[0] consume # within[fun( x: ANY ) m2 feed filter[.A = 0] {s} loopjoin[x feed] count] # # Index Nested Loop (47.66 s) # m2 feed {s} filter[(.B_s = 1)] filter[(.A_s = 0)] loopjoin[m1_A m1 exactmatch[.A_s] {r} ] count # # Adaptive (hj = 20.09 s) => Selectivity estimation error 100% !!! # # #secondo('query m2 pfeed[100] puse[. {s} filter[(.B_s = 1)] filter[(.A_s = 0)] ] m1 pjoin1[1; symj: . .. feed head[1000] {1} {r} head[500] {2} symmjoin[(.A_s = ..A_r)] {4}, hj: . .. feed {r} {3} hashjoin[A_s, A_r, 9997] , smj: . .. feed {r} {3} sortmergejoin[A_s, A_r] , ilj: . loopjoin[m1_A .. exactmatch[.A_s] {r} {3} ] ] pdelete count')