tpch_create_index.slt 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Plans for the TPC-H workload modeled as CREATE INDEX statements
  10. # on views for each workload query.
  11. # PRIMARY KEY annotations (which are in the spec) are currently
  12. # removed from this slt, because we don't support them at the moment.
  13. # (Note that _in slts_ they are actually supported, but it's better
  14. # to match the plans of real runs more closely.)
  15. statement ok
  16. CREATE TABLE nation (
  17. n_nationkey integer,
  18. n_name char(25) NOT NULL,
  19. n_regionkey integer NOT NULL,
  20. n_comment varchar(152)
  21. );
  22. statement ok
  23. CREATE INDEX pk_nation_nationkey ON nation (n_nationkey ASC);
  24. statement ok
  25. CREATE INDEX fk_nation_regionkey ON nation (n_regionkey ASC);
  26. statement ok
  27. CREATE TABLE region (
  28. r_regionkey integer,
  29. r_name char(25) NOT NULL,
  30. r_comment varchar(152)
  31. );
  32. statement ok
  33. CREATE INDEX pk_region_regionkey ON region (r_regionkey ASC);
  34. statement ok
  35. CREATE TABLE part (
  36. p_partkey integer,
  37. p_name varchar(55) NOT NULL,
  38. p_mfgr char(25) NOT NULL,
  39. p_brand char(10) NOT NULL,
  40. p_type varchar(25) NOT NULL,
  41. p_size integer NOT NULL,
  42. p_container char(10) NOT NULL,
  43. p_retailprice decimal(15, 2) NOT NULL,
  44. p_comment varchar(23) NOT NULL
  45. );
  46. statement ok
  47. CREATE INDEX pk_part_partkey ON part (p_partkey ASC);
  48. statement ok
  49. CREATE TABLE supplier (
  50. s_suppkey integer,
  51. s_name char(25) NOT NULL,
  52. s_address varchar(40) NOT NULL,
  53. s_nationkey integer NOT NULL,
  54. s_phone char(15) NOT NULL,
  55. s_acctbal decimal(15, 2) NOT NULL,
  56. s_comment varchar(101) NOT NULL
  57. );
  58. statement ok
  59. CREATE INDEX pk_supplier_suppkey ON supplier (s_suppkey ASC);
  60. statement ok
  61. CREATE INDEX fk_supplier_nationkey ON supplier (s_nationkey ASC);
  62. statement ok
  63. CREATE TABLE partsupp (
  64. ps_partkey integer NOT NULL,
  65. ps_suppkey integer NOT NULL,
  66. ps_availqty integer NOT NULL,
  67. ps_supplycost decimal(15, 2) NOT NULL,
  68. ps_comment varchar(199) NOT NULL
  69. );
  70. statement ok
  71. CREATE INDEX pk_partsupp_partkey_suppkey ON partsupp (ps_partkey ASC, ps_suppkey ASC);
  72. statement ok
  73. CREATE INDEX fk_partsupp_partkey ON partsupp (ps_partkey ASC);
  74. statement ok
  75. CREATE INDEX fk_partsupp_suppkey ON partsupp (ps_suppkey ASC);
  76. statement ok
  77. CREATE TABLE customer (
  78. c_custkey integer,
  79. c_name varchar(25) NOT NULL,
  80. c_address varchar(40) NOT NULL,
  81. c_nationkey integer NOT NULL,
  82. c_phone char(15) NOT NULL,
  83. c_acctbal decimal(15, 2) NOT NULL,
  84. c_mktsegment char(10) NOT NULL,
  85. c_comment varchar(117) NOT NULL
  86. );
  87. statement ok
  88. CREATE INDEX pk_customer_custkey ON customer (c_custkey ASC);
  89. statement ok
  90. CREATE INDEX fk_customer_nationkey ON customer (c_nationkey ASC);
  91. statement ok
  92. CREATE TABLE orders (
  93. o_orderkey integer,
  94. o_custkey integer NOT NULL,
  95. o_orderstatus char(1) NOT NULL,
  96. o_totalprice decimal(15, 2) NOT NULL,
  97. o_orderdate DATE NOT NULL,
  98. o_orderpriority char(15) NOT NULL,
  99. o_clerk char(15) NOT NULL,
  100. o_shippriority integer NOT NULL,
  101. o_comment varchar(79) NOT NULL
  102. );
  103. statement ok
  104. CREATE INDEX pk_orders_orderkey ON orders (o_orderkey ASC);
  105. statement ok
  106. CREATE INDEX fk_orders_custkey ON orders (o_custkey ASC);
  107. statement ok
  108. CREATE TABLE lineitem (
  109. l_orderkey integer NOT NULL,
  110. l_partkey integer NOT NULL,
  111. l_suppkey integer NOT NULL,
  112. l_linenumber integer NOT NULL,
  113. l_quantity decimal(15, 2) NOT NULL,
  114. l_extendedprice decimal(15, 2) NOT NULL,
  115. l_discount decimal(15, 2) NOT NULL,
  116. l_tax decimal(15, 2) NOT NULL,
  117. l_returnflag char(1) NOT NULL,
  118. l_linestatus char(1) NOT NULL,
  119. l_shipdate date NOT NULL,
  120. l_commitdate date NOT NULL,
  121. l_receiptdate date NOT NULL,
  122. l_shipinstruct char(25) NOT NULL,
  123. l_shipmode char(10) NOT NULL,
  124. l_comment varchar(44) NOT NULL
  125. );
  126. statement ok
  127. CREATE INDEX pk_lineitem_orderkey_linenumber ON lineitem (l_orderkey ASC, l_linenumber ASC);
  128. statement ok
  129. CREATE INDEX fk_lineitem_orderkey ON lineitem (l_orderkey ASC);
  130. statement ok
  131. CREATE INDEX fk_lineitem_partkey ON lineitem (l_partkey ASC);
  132. statement ok
  133. CREATE INDEX fk_lineitem_suppkey ON lineitem (l_suppkey ASC);
  134. statement ok
  135. CREATE INDEX fk_lineitem_partsuppkey ON lineitem (l_partkey ASC, l_suppkey ASC);
  136. statement ok
  137. -- Query 01
  138. CREATE VIEW Q01 AS
  139. SELECT
  140. l_returnflag,
  141. l_linestatus,
  142. sum(l_quantity) AS sum_qty,
  143. sum(l_extendedprice) AS sum_base_price,
  144. sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price,
  145. sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge,
  146. avg(l_quantity) AS avg_qty,
  147. avg(l_extendedprice) AS avg_price,
  148. avg(l_discount) AS avg_disc,
  149. count(*) AS count_order
  150. FROM
  151. lineitem
  152. WHERE
  153. l_shipdate <= DATE '1998-12-01' - INTERVAL '60' day
  154. GROUP BY
  155. l_returnflag,
  156. l_linestatus
  157. ORDER BY
  158. l_returnflag,
  159. l_linestatus;
  160. query T multiline
  161. -- Explain index on Q01
  162. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  163. CREATE DEFAULT INDEX ON Q01;
  164. ----
  165. materialize.public.q01_primary_idx:
  166. ArrangeBy keys=[[#0{l_returnflag}, #1{l_linestatus}]] // { arity: 10 }
  167. ReadGlobalFromSameDataflow materialize.public.q01 // { arity: 10 }
  168. materialize.public.q01:
  169. Project (#0{l_returnflag}..=#5{sum}, #9..=#11, #6{count}) // { arity: 10 }
  170. Map (bigint_to_numeric(case when (#6{count} = 0) then null else #6{count} end), (#2{sum_l_quantity} / #8), (#3{sum_l_extendedprice} / #8), (#7{sum_l_discount} / #8)) // { arity: 12 }
  171. Reduce group_by=[#4{l_returnflag}, #5{l_linestatus}] aggregates=[sum(#0{l_quantity}), sum(#1{l_extendedprice}), sum((#1{l_extendedprice} * (1 - #2{l_discount}))), sum(((#1{l_extendedprice} * (1 - #2{l_discount})) * (1 + #3{l_tax}))), count(*), sum(#2{l_discount})] // { arity: 8 }
  172. Project (#4{l_quantity}..=#9{l_linestatus}) // { arity: 6 }
  173. Filter (date_to_timestamp(#10{l_shipdate}) <= 1998-10-02 00:00:00) // { arity: 16 }
  174. ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 16 }
  175. Used Indexes:
  176. - materialize.public.pk_lineitem_orderkey_linenumber (*** full scan ***)
  177. Target cluster: quickstart
  178. EOF
  179. # Create a default index on Q01 in order to ensure that the EXPLAIN CREATE INDEX
  180. # output does not produce a plan that just reads from the explained index if it
  181. # already exists.
  182. statement ok
  183. CREATE DEFAULT INDEX ON Q01;
  184. statement ok
  185. -- Query 02
  186. CREATE VIEW Q02 AS
  187. SELECT
  188. s_acctbal,
  189. s_name,
  190. n_name,
  191. p_partkey,
  192. p_mfgr,
  193. s_address,
  194. s_phone,
  195. s_comment
  196. FROM
  197. part, supplier, partsupp, nation, region
  198. WHERE
  199. p_partkey = ps_partkey
  200. AND s_suppkey = ps_suppkey
  201. AND p_size = CAST (15 AS smallint)
  202. AND p_type LIKE '%BRASS'
  203. AND s_nationkey = n_nationkey
  204. AND n_regionkey = r_regionkey
  205. AND r_name = 'EUROPE'
  206. AND ps_supplycost
  207. = (
  208. SELECT
  209. min(ps_supplycost)
  210. FROM
  211. partsupp, supplier, nation, region
  212. WHERE
  213. p_partkey = ps_partkey
  214. AND s_suppkey = ps_suppkey
  215. AND s_nationkey = n_nationkey
  216. AND n_regionkey = r_regionkey
  217. AND r_name = 'EUROPE'
  218. )
  219. ORDER BY
  220. s_acctbal DESC, n_name, s_name, p_partkey;
  221. query T multiline
  222. -- Explain index on Q02
  223. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  224. CREATE DEFAULT INDEX ON Q02;
  225. ----
  226. materialize.public.q02_primary_idx:
  227. ArrangeBy keys=[[#0{s_acctbal}..=#7{s_comment}]] // { arity: 8 }
  228. ReadGlobalFromSameDataflow materialize.public.q02 // { arity: 8 }
  229. materialize.public.q02:
  230. With
  231. cte l0 =
  232. ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 }
  233. ReadIndex on=supplier pk_supplier_suppkey=[delta join lookup] fk_supplier_nationkey=[delta join lookup] // { arity: 7 }
  234. cte l1 =
  235. ArrangeBy keys=[[#0{ps_partkey}], [#1{ps_suppkey}]] // { arity: 5 }
  236. ReadIndex on=partsupp fk_partsupp_partkey=[delta join lookup] fk_partsupp_suppkey=[delta join lookup] // { arity: 5 }
  237. cte l2 =
  238. ArrangeBy keys=[[#0{n_nationkey}], [#2{n_regionkey}]] // { arity: 4 }
  239. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] fk_nation_regionkey=[delta join lookup] // { arity: 4 }
  240. cte l3 =
  241. ArrangeBy keys=[[#0{r_regionkey}]] // { arity: 3 }
  242. ReadIndex on=region pk_region_regionkey=[delta join lookup] // { arity: 3 }
  243. cte l4 =
  244. Project (#0{p_partkey}, #2{p_mfgr}, #10{s_name}, #11{s_address}, #13{s_phone}..=#15{s_comment}, #19{ps_supplycost}, #22{n_name}) // { arity: 9 }
  245. Filter (#5{p_size} = 15) AND (#26{r_name} = "EUROPE") AND like["%BRASS"](varchar_to_text(#4{p_type})) // { arity: 28 }
  246. Join on=(#0{p_partkey} = #16{ps_partkey} AND #9{s_suppkey} = #17{ps_suppkey} AND #12{s_nationkey} = #21{n_nationkey} AND #23{n_regionkey} = #25{r_regionkey}) type=delta // { arity: 28 }
  247. implementation
  248. %0:part » %2:l1[#0{ps_partkey}]KA » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef
  249. %1:l0 » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef
  250. %2:l1 » %0:part[#0{p_partkey}]KAelf » %1:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef
  251. %3:l2 » %4:l3[#0{r_regionkey}]KAef » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf
  252. %4:l3 » %3:l2[#2{n_regionkey}]KA » %1:l0[#3{s_nationkey}]KA » %2:l1[#1{ps_suppkey}]KA » %0:part[#0{p_partkey}]KAelf
  253. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  254. ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 }
  255. Get l0 // { arity: 7 }
  256. Get l1 // { arity: 5 }
  257. Get l2 // { arity: 4 }
  258. Get l3 // { arity: 3 }
  259. Return // { arity: 8 }
  260. Project (#5{s_acctbal}, #2{s_name}, #8{n_name}, #0{p_partkey}, #1{p_mfgr}, #3{s_address}, #4{s_phone}, #6{s_comment}) // { arity: 8 }
  261. Join on=(#0{p_partkey} = #9{p_partkey} AND #7{ps_supplycost} = #10{min_ps_supplycost}) type=differential // { arity: 11 }
  262. implementation
  263. %1[#0, #1]UKK » %0:l4[#0, #7{ps_supplycost}]KK
  264. ArrangeBy keys=[[#0{p_partkey}, #7{ps_supplycost}]] // { arity: 9 }
  265. Get l4 // { arity: 9 }
  266. ArrangeBy keys=[[#0{p_partkey}, #1{min_ps_supplycost}]] // { arity: 2 }
  267. Reduce group_by=[#0{p_partkey}] aggregates=[min(#1{ps_supplycost})] // { arity: 2 }
  268. Project (#0{p_partkey}, #4{ps_supplycost}) // { arity: 2 }
  269. Filter (#18{r_name} = "EUROPE") // { arity: 20 }
  270. Join on=(#0{p_partkey} = #1{ps_partkey} AND #2{ps_suppkey} = #6{s_suppkey} AND #9{s_nationkey} = #13{n_nationkey} AND #15{n_regionkey} = #17{r_regionkey}) type=delta // { arity: 20 }
  271. implementation
  272. %0 » %1:l1[#0{ps_partkey}]KA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef
  273. %1:l1 » %0[#0]UKA » %2:l0[#0{s_suppkey}]KA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef
  274. %2:l0 » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA » %3:l2[#0{n_nationkey}]KA » %4:l3[#0{r_regionkey}]KAef
  275. %3:l2 » %4:l3[#0{r_regionkey}]KAef » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA
  276. %4:l3 » %3:l2[#2{n_regionkey}]KA » %2:l0[#3{s_nationkey}]KA » %1:l1[#1{ps_suppkey}]KA » %0[#0]UKA
  277. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 1 }
  278. Distinct project=[#0{p_partkey}] // { arity: 1 }
  279. Project (#0{p_partkey}) // { arity: 1 }
  280. Get l4 // { arity: 9 }
  281. Get l1 // { arity: 5 }
  282. Get l0 // { arity: 7 }
  283. Get l2 // { arity: 4 }
  284. Get l3 // { arity: 3 }
  285. Used Indexes:
  286. - materialize.public.pk_nation_nationkey (delta join lookup)
  287. - materialize.public.fk_nation_regionkey (delta join lookup)
  288. - materialize.public.pk_region_regionkey (delta join lookup)
  289. - materialize.public.pk_part_partkey (delta join 1st input (full scan))
  290. - materialize.public.pk_supplier_suppkey (delta join lookup)
  291. - materialize.public.fk_supplier_nationkey (delta join lookup)
  292. - materialize.public.fk_partsupp_partkey (delta join lookup)
  293. - materialize.public.fk_partsupp_suppkey (delta join lookup)
  294. Target cluster: quickstart
  295. EOF
  296. statement ok
  297. -- Query 03
  298. CREATE VIEW Q03 AS
  299. SELECT
  300. l_orderkey,
  301. sum(l_extendedprice * (1 - l_discount)) AS revenue,
  302. o_orderdate,
  303. o_shippriority
  304. FROM
  305. customer,
  306. orders,
  307. lineitem
  308. WHERE
  309. c_mktsegment = 'BUILDING'
  310. AND c_custkey = o_custkey
  311. AND l_orderkey = o_orderkey
  312. AND o_orderdate < DATE '1995-03-15'
  313. AND l_shipdate > DATE '1995-03-15'
  314. GROUP BY
  315. l_orderkey,
  316. o_orderdate,
  317. o_shippriority
  318. ORDER BY
  319. revenue DESC,
  320. o_orderdate;
  321. query T multiline
  322. -- Explain index on Q03
  323. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  324. CREATE DEFAULT INDEX ON Q03;
  325. ----
  326. materialize.public.q03_primary_idx:
  327. ArrangeBy keys=[[#0{l_orderkey}, #2{o_orderdate}, #3{o_shippriority}]] // { arity: 4 }
  328. ReadGlobalFromSameDataflow materialize.public.q03 // { arity: 4 }
  329. materialize.public.q03:
  330. Project (#0{o_orderkey}, #3{sum}, #1{o_orderdate}, #2{o_shippriority}) // { arity: 4 }
  331. Reduce group_by=[#0{o_orderkey}..=#2{o_shippriority}] aggregates=[sum((#3{l_extendedprice} * (1 - #4{l_discount})))] // { arity: 4 }
  332. Project (#8{o_orderkey}, #12{o_orderdate}, #15{o_shippriority}, #22{l_extendedprice}, #23{l_discount}) // { arity: 5 }
  333. Filter (#6{c_mktsegment} = "BUILDING") AND (#12{o_orderdate} < 1995-03-15) AND (#27{l_shipdate} > 1995-03-15) // { arity: 33 }
  334. Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 }
  335. implementation
  336. %0:customer » %1:orders[#1{o_custkey}]KAif » %2:lineitem[#0{l_orderkey}]KAif
  337. %1:orders » %0:customer[#0{c_custkey}]KAef » %2:lineitem[#0{l_orderkey}]KAif
  338. %2:lineitem » %1:orders[#0{o_orderkey}]KAif » %0:customer[#0{c_custkey}]KAef
  339. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 }
  340. ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 }
  341. ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 }
  342. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] fk_orders_custkey=[delta join lookup] // { arity: 9 }
  343. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 }
  344. ReadIndex on=lineitem fk_lineitem_orderkey=[delta join lookup] // { arity: 16 }
  345. Used Indexes:
  346. - materialize.public.pk_customer_custkey (delta join 1st input (full scan))
  347. - materialize.public.pk_orders_orderkey (delta join lookup)
  348. - materialize.public.fk_orders_custkey (delta join lookup)
  349. - materialize.public.fk_lineitem_orderkey (delta join lookup)
  350. Target cluster: quickstart
  351. EOF
  352. statement ok
  353. -- Query 04
  354. CREATE VIEW Q04 AS
  355. SELECT
  356. o_orderpriority,
  357. count(*) AS order_count
  358. FROM
  359. orders
  360. WHERE
  361. o_orderdate >= DATE '1993-07-01'
  362. AND o_orderdate < DATE '1993-07-01' + INTERVAL '3' month
  363. AND EXISTS (
  364. SELECT
  365. *
  366. FROM
  367. lineitem
  368. WHERE
  369. l_orderkey = o_orderkey
  370. AND l_commitdate < l_receiptdate
  371. )
  372. GROUP BY
  373. o_orderpriority
  374. ORDER BY
  375. o_orderpriority;
  376. query T multiline
  377. -- Explain index on Q04
  378. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  379. CREATE DEFAULT INDEX ON Q04;
  380. ----
  381. materialize.public.q04_primary_idx:
  382. ArrangeBy keys=[[#0{o_orderpriority}]] // { arity: 2 }
  383. ReadGlobalFromSameDataflow materialize.public.q04 // { arity: 2 }
  384. materialize.public.q04:
  385. Reduce group_by=[#0{o_orderpriority}] aggregates=[count(*)] // { arity: 2 }
  386. Project (#5{o_orderpriority}) // { arity: 1 }
  387. Filter (#4{o_orderdate} >= 1993-07-01) AND (date_to_timestamp(#4{o_orderdate}) < 1993-10-01 00:00:00) // { arity: 10 }
  388. Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 10 }
  389. implementation
  390. %1[#0]UKA » %0:orders[#0{o_orderkey}]KAiif
  391. ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 }
  392. ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 }
  393. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 1 }
  394. Distinct project=[#0{l_orderkey}] // { arity: 1 }
  395. Project (#0{l_orderkey}) // { arity: 1 }
  396. Filter (#11{l_commitdate} < #12{l_receiptdate}) // { arity: 16 }
  397. ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 16 }
  398. Used Indexes:
  399. - materialize.public.pk_orders_orderkey (differential join)
  400. - materialize.public.pk_lineitem_orderkey_linenumber (*** full scan ***)
  401. Target cluster: quickstart
  402. EOF
  403. statement ok
  404. -- Query 05
  405. CREATE VIEW Q05 AS
  406. SELECT
  407. n_name,
  408. sum(l_extendedprice * (1 - l_discount)) AS revenue
  409. FROM
  410. customer,
  411. orders,
  412. lineitem,
  413. supplier,
  414. nation,
  415. region
  416. WHERE
  417. c_custkey = o_custkey
  418. AND l_orderkey = o_orderkey
  419. AND l_suppkey = s_suppkey
  420. AND c_nationkey = s_nationkey
  421. AND s_nationkey = n_nationkey
  422. AND n_regionkey = r_regionkey
  423. AND r_name = 'ASIA'
  424. AND o_orderdate >= DATE '1994-01-01'
  425. AND o_orderdate < DATE '1995-01-01'
  426. GROUP BY
  427. n_name
  428. ORDER BY
  429. revenue DESC;
  430. query T multiline
  431. -- Explain index on Q05
  432. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  433. CREATE DEFAULT INDEX ON Q05;
  434. ----
  435. materialize.public.q05_primary_idx:
  436. ArrangeBy keys=[[#0{n_name}]] // { arity: 2 }
  437. ReadGlobalFromSameDataflow materialize.public.q05 // { arity: 2 }
  438. materialize.public.q05:
  439. Reduce group_by=[#2{n_name}] aggregates=[sum((#0{l_extendedprice} * (1 - #1{l_discount})))] // { arity: 2 }
  440. Project (#19{l_extendedprice}, #20{l_discount}, #24{n_name}) // { arity: 3 }
  441. Filter (#28{r_name} = "ASIA") AND (#12{o_orderdate} < 1995-01-01) AND (#12{o_orderdate} >= 1994-01-01) // { arity: 30 }
  442. Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #22{s_nationkey} = #23{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey} AND #18{l_suppkey} = #21{s_suppkey} AND #25{n_regionkey} = #27{r_regionkey}) type=delta // { arity: 30 }
  443. implementation
  444. %0:customer » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#0{s_suppkey}, #1{s_nationkey}]KK » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef
  445. %1:orders » %0:customer[#0{c_custkey}]KA » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#0{s_suppkey}, #1{s_nationkey}]KK » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef
  446. %2:lineitem » %1:orders[#0{o_orderkey}]KAiif » %0:customer[#0{c_custkey}]KA » %3:supplier[#0{s_suppkey}, #1{s_nationkey}]KK » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef
  447. %3:supplier » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}, #1{l_suppkey}]KK » %4:nation[#0{n_nationkey}]KA » %5:region[#0{r_regionkey}]KAef
  448. %4:nation » %5:region[#0{r_regionkey}]KAef » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#0{s_suppkey}, #1{s_nationkey}]KK
  449. %5:region » %4:nation[#2{n_regionkey}]KA » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %3:supplier[#0{s_suppkey}, #1{s_nationkey}]KK
  450. ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 }
  451. ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 }
  452. ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 }
  453. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] fk_orders_custkey=[delta join lookup] // { arity: 9 }
  454. ArrangeBy keys=[[#0{l_orderkey}], [#0{l_orderkey}, #1{l_suppkey}]] // { arity: 4 }
  455. Project (#0{l_orderkey}, #2{l_suppkey}, #5{l_extendedprice}, #6{l_discount}) // { arity: 4 }
  456. ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 16 }
  457. ArrangeBy keys=[[#0{s_suppkey}, #1{s_nationkey}]] // { arity: 2 }
  458. Project (#0{s_suppkey}, #3{s_nationkey}) // { arity: 2 }
  459. Filter (#0{s_suppkey}) IS NOT NULL // { arity: 7 }
  460. ReadIndex on=supplier pk_supplier_suppkey=[*** full scan ***] // { arity: 7 }
  461. ArrangeBy keys=[[#0{n_nationkey}], [#2{n_regionkey}]] // { arity: 4 }
  462. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] fk_nation_regionkey=[delta join lookup] // { arity: 4 }
  463. ArrangeBy keys=[[#0{r_regionkey}]] // { arity: 3 }
  464. ReadIndex on=region pk_region_regionkey=[delta join lookup] // { arity: 3 }
  465. Used Indexes:
  466. - materialize.public.pk_nation_nationkey (delta join lookup)
  467. - materialize.public.fk_nation_regionkey (delta join lookup)
  468. - materialize.public.pk_region_regionkey (delta join lookup)
  469. - materialize.public.pk_supplier_suppkey (*** full scan ***)
  470. - materialize.public.pk_customer_custkey (delta join 1st input (full scan))
  471. - materialize.public.fk_customer_nationkey (delta join lookup)
  472. - materialize.public.pk_orders_orderkey (delta join lookup)
  473. - materialize.public.fk_orders_custkey (delta join lookup)
  474. - materialize.public.pk_lineitem_orderkey_linenumber (*** full scan ***)
  475. Target cluster: quickstart
  476. EOF
  477. statement ok
  478. -- Query 06
  479. CREATE VIEW Q06 AS
  480. SELECT
  481. sum(l_extendedprice * l_discount) AS revenue
  482. FROM
  483. lineitem
  484. WHERE
  485. l_quantity < 24
  486. AND l_shipdate >= DATE '1994-01-01'
  487. AND l_shipdate < DATE '1994-01-01' + INTERVAL '1' year
  488. AND l_discount BETWEEN 0.06 - 0.01 AND 0.07;
  489. query T multiline
  490. -- Explain index on Q06
  491. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  492. CREATE DEFAULT INDEX ON Q06;
  493. ----
  494. materialize.public.q06_primary_idx:
  495. ArrangeBy keys=[[#0{revenue}]] // { arity: 1 }
  496. ReadGlobalFromSameDataflow materialize.public.q06 // { arity: 1 }
  497. materialize.public.q06:
  498. With
  499. cte l0 =
  500. Reduce aggregates=[sum((#0{l_extendedprice} * #1{l_discount}))] // { arity: 1 }
  501. Project (#5{l_extendedprice}, #6{l_discount}) // { arity: 2 }
  502. Filter (#4{l_quantity} < 24) AND (#6{l_discount} <= 0.07) AND (#6{l_discount} >= 0.05) AND (#10{l_shipdate} >= 1994-01-01) AND (date_to_timestamp(#10{l_shipdate}) < 1995-01-01 00:00:00) // { arity: 16 }
  503. ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 16 }
  504. Return // { arity: 1 }
  505. Union // { arity: 1 }
  506. Get l0 // { arity: 1 }
  507. Map (null) // { arity: 1 }
  508. Union // { arity: 0 }
  509. Negate // { arity: 0 }
  510. Project () // { arity: 0 }
  511. Get l0 // { arity: 1 }
  512. Constant // { arity: 0 }
  513. - ()
  514. Used Indexes:
  515. - materialize.public.pk_lineitem_orderkey_linenumber (*** full scan ***)
  516. Target cluster: quickstart
  517. EOF
  518. statement ok
  519. -- Query 07
  520. CREATE VIEW Q07 AS
  521. SELECT
  522. supp_nation,
  523. cust_nation,
  524. l_year,
  525. sum(volume) AS revenue
  526. FROM
  527. (
  528. SELECT
  529. n1.n_name AS supp_nation,
  530. n2.n_name AS cust_nation,
  531. extract(year FROM l_shipdate) AS l_year,
  532. l_extendedprice * (1 - l_discount) AS volume
  533. FROM
  534. supplier,
  535. lineitem,
  536. orders,
  537. customer,
  538. nation n1,
  539. nation n2
  540. WHERE
  541. s_suppkey = l_suppkey
  542. AND o_orderkey = l_orderkey
  543. AND c_custkey = o_custkey
  544. AND s_nationkey = n1.n_nationkey
  545. AND c_nationkey = n2.n_nationkey
  546. AND (
  547. (n1.n_name = 'FRANCE' AND n2.n_name = 'GERMANY')
  548. or (n1.n_name = 'GERMANY' AND n2.n_name = 'FRANCE')
  549. )
  550. AND l_shipdate BETWEEN DATE '1995-01-01' AND DATE '1996-12-31'
  551. ) AS shipping
  552. GROUP BY
  553. supp_nation,
  554. cust_nation,
  555. l_year
  556. ORDER BY
  557. supp_nation,
  558. cust_nation,
  559. l_year;
  560. query T multiline
  561. -- Explain index on Q07
  562. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  563. CREATE DEFAULT INDEX ON Q07;
  564. ----
  565. materialize.public.q07_primary_idx:
  566. ArrangeBy keys=[[#0{supp_nation}..=#2{l_year}]] // { arity: 4 }
  567. ReadGlobalFromSameDataflow materialize.public.q07 // { arity: 4 }
  568. materialize.public.q07:
  569. With
  570. cte l0 =
  571. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  572. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] // { arity: 4 }
  573. Return // { arity: 4 }
  574. Reduce group_by=[#3{n_name}, #4{n_name}, extract_year_d(#2{l_shipdate})] aggregates=[sum((#0{l_extendedprice} * (1 - #1{l_discount})))] // { arity: 4 }
  575. Project (#12{l_extendedprice}, #13{l_discount}, #17{l_shipdate}, #41{n_name}, #45{n_name}) // { arity: 5 }
  576. Filter (#17{l_shipdate} <= 1996-12-31) AND (#17{l_shipdate} >= 1995-01-01) AND (#48 OR #49) AND (#50 OR #51) AND ((#48 AND #51) OR (#49 AND #50)) // { arity: 52 }
  577. Map ((#41{n_name} = "FRANCE"), (#41{n_name} = "GERMANY"), (#45{n_name} = "FRANCE"), (#45{n_name} = "GERMANY")) // { arity: 52 }
  578. Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #40{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey} AND #24{o_custkey} = #32{c_custkey} AND #35{c_nationkey} = #44{n_nationkey}) type=delta // { arity: 48 }
  579. implementation
  580. %0:supplier » %4:l0[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef
  581. %1:lineitem » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef
  582. %2:orders » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef
  583. %3:customer » %5:l0[#0{n_nationkey}]KAef » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef
  584. %4:l0 » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAiif » %2:orders[#0{o_orderkey}]KA » %3:customer[#0{c_custkey}]KA » %5:l0[#0{n_nationkey}]KAef
  585. %5:l0 » %3:customer[#3{c_nationkey}]KA » %2:orders[#1{o_custkey}]KA » %1:lineitem[#0{l_orderkey}]KAiif » %0:supplier[#0{s_suppkey}]KA » %4:l0[#0{n_nationkey}]KAef
  586. ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 }
  587. ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 }
  588. ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 }
  589. ReadIndex on=lineitem fk_lineitem_orderkey=[delta join lookup] fk_lineitem_suppkey=[delta join lookup] // { arity: 16 }
  590. ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 }
  591. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] fk_orders_custkey=[delta join lookup] // { arity: 9 }
  592. ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 }
  593. ReadIndex on=customer pk_customer_custkey=[delta join lookup] fk_customer_nationkey=[delta join lookup] // { arity: 8 }
  594. Get l0 // { arity: 4 }
  595. Get l0 // { arity: 4 }
  596. Used Indexes:
  597. - materialize.public.pk_nation_nationkey (delta join lookup)
  598. - materialize.public.pk_supplier_suppkey (delta join 1st input (full scan))
  599. - materialize.public.fk_supplier_nationkey (delta join lookup)
  600. - materialize.public.pk_customer_custkey (delta join lookup)
  601. - materialize.public.fk_customer_nationkey (delta join lookup)
  602. - materialize.public.pk_orders_orderkey (delta join lookup)
  603. - materialize.public.fk_orders_custkey (delta join lookup)
  604. - materialize.public.fk_lineitem_orderkey (delta join lookup)
  605. - materialize.public.fk_lineitem_suppkey (delta join lookup)
  606. Target cluster: quickstart
  607. EOF
  608. statement ok
  609. -- Query 08
  610. CREATE VIEW Q08 AS
  611. SELECT
  612. o_year,
  613. sum(case
  614. when nation = 'BRAZIL' then volume
  615. else 0
  616. end) / sum(volume) AS mkt_share
  617. FROM
  618. (
  619. SELECT
  620. extract(year FROM o_orderdate) AS o_year,
  621. l_extendedprice * (1 - l_discount) AS volume,
  622. n2.n_name AS nation
  623. FROM
  624. part,
  625. supplier,
  626. lineitem,
  627. orders,
  628. customer,
  629. nation n1,
  630. nation n2,
  631. region
  632. WHERE
  633. p_partkey = l_partkey
  634. AND s_suppkey = l_suppkey
  635. AND l_orderkey = o_orderkey
  636. AND o_custkey = c_custkey
  637. AND c_nationkey = n1.n_nationkey
  638. AND n1.n_regionkey = r_regionkey
  639. AND r_name = 'AMERICA'
  640. AND s_nationkey = n2.n_nationkey
  641. AND o_orderdate BETWEEN DATE '1995-01-01' AND DATE '1996-12-31'
  642. AND p_type = 'ECONOMY ANODIZED STEEL'
  643. ) AS all_nations
  644. GROUP BY
  645. o_year
  646. ORDER BY
  647. o_year;
  648. query T multiline
  649. -- Explain index on Q08
  650. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  651. CREATE DEFAULT INDEX ON Q08;
  652. ----
  653. materialize.public.q08_primary_idx:
  654. ArrangeBy keys=[[#0{o_year}]] // { arity: 2 }
  655. ReadGlobalFromSameDataflow materialize.public.q08 // { arity: 2 }
  656. materialize.public.q08:
  657. Project (#0, #3) // { arity: 2 }
  658. Map ((#1{sum} / #2{sum})) // { arity: 4 }
  659. Reduce group_by=[extract_year_d(#2{o_orderdate})] aggregates=[sum(case when (#3{n_name} = "BRAZIL") then (#0{l_extendedprice} * (1 - #1{l_discount})) else 0 end), sum((#0{l_extendedprice} * (1 - #1{l_discount})))] // { arity: 3 }
  660. Project (#21{l_extendedprice}, #22{l_discount}, #36{o_orderdate}, #54{n_name}) // { arity: 4 }
  661. Filter (#58{r_name} = "AMERICA") AND (#36{o_orderdate} <= 1996-12-31) AND (#36{o_orderdate} >= 1995-01-01) AND ("ECONOMY ANODIZED STEEL" = varchar_to_text(#4{p_type})) // { arity: 60 }
  662. Join on=(#0{p_partkey} = #17{l_partkey} AND #9{s_suppkey} = #18{l_suppkey} AND #12{s_nationkey} = #53{n_nationkey} AND #16{l_orderkey} = #32{o_orderkey} AND #33{o_custkey} = #41{c_custkey} AND #44{c_nationkey} = #49{n_nationkey} AND #51{n_regionkey} = #57{r_regionkey}) type=delta // { arity: 60 }
  663. implementation
  664. %0:part » %2:lineitem[#1{l_partkey}]KA » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA
  665. %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA
  666. %2:lineitem » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA
  667. %3:orders » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA
  668. %4:customer » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef » %6:nation[#0{n_nationkey}]KA
  669. %5:nation » %7:region[#0{r_regionkey}]KAef » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA
  670. %6:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %0:part[#0{p_partkey}]KAef » %3:orders[#0{o_orderkey}]KAiif » %4:customer[#0{c_custkey}]KA » %5:nation[#0{n_nationkey}]KA » %7:region[#0{r_regionkey}]KAef
  671. %7:region » %5:nation[#2{n_regionkey}]KA » %4:customer[#3{c_nationkey}]KA » %3:orders[#1{o_custkey}]KAiif » %2:lineitem[#0{l_orderkey}]KA » %0:part[#0{p_partkey}]KAef » %1:supplier[#0{s_suppkey}]KA » %6:nation[#0{n_nationkey}]KA
  672. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  673. ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 }
  674. ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 }
  675. ReadIndex on=supplier pk_supplier_suppkey=[delta join lookup] fk_supplier_nationkey=[delta join lookup] // { arity: 7 }
  676. ArrangeBy keys=[[#0{l_orderkey}], [#1{l_partkey}], [#2{l_suppkey}]] // { arity: 16 }
  677. ReadIndex on=lineitem fk_lineitem_orderkey=[delta join lookup] fk_lineitem_partkey=[delta join lookup] fk_lineitem_suppkey=[delta join lookup] // { arity: 16 }
  678. ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 }
  679. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] fk_orders_custkey=[delta join lookup] // { arity: 9 }
  680. ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 }
  681. ReadIndex on=customer pk_customer_custkey=[delta join lookup] fk_customer_nationkey=[delta join lookup] // { arity: 8 }
  682. ArrangeBy keys=[[#0{n_nationkey}], [#2{n_regionkey}]] // { arity: 4 }
  683. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] fk_nation_regionkey=[delta join lookup] // { arity: 4 }
  684. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  685. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] // { arity: 4 }
  686. ArrangeBy keys=[[#0{r_regionkey}]] // { arity: 3 }
  687. ReadIndex on=region pk_region_regionkey=[delta join lookup] // { arity: 3 }
  688. Used Indexes:
  689. - materialize.public.pk_nation_nationkey (delta join lookup)
  690. - materialize.public.fk_nation_regionkey (delta join lookup)
  691. - materialize.public.pk_region_regionkey (delta join lookup)
  692. - materialize.public.pk_part_partkey (delta join 1st input (full scan))
  693. - materialize.public.pk_supplier_suppkey (delta join lookup)
  694. - materialize.public.fk_supplier_nationkey (delta join lookup)
  695. - materialize.public.pk_customer_custkey (delta join lookup)
  696. - materialize.public.fk_customer_nationkey (delta join lookup)
  697. - materialize.public.pk_orders_orderkey (delta join lookup)
  698. - materialize.public.fk_orders_custkey (delta join lookup)
  699. - materialize.public.fk_lineitem_orderkey (delta join lookup)
  700. - materialize.public.fk_lineitem_partkey (delta join lookup)
  701. - materialize.public.fk_lineitem_suppkey (delta join lookup)
  702. Target cluster: quickstart
  703. EOF
  704. statement ok
  705. -- Query 09
  706. CREATE VIEW Q09 AS
  707. SELECT
  708. nation,
  709. o_year,
  710. sum(amount) AS sum_profit
  711. FROM
  712. (
  713. SELECT
  714. n_name AS nation,
  715. extract(year FROM o_orderdate) AS o_year,
  716. l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity AS amount
  717. FROM
  718. part,
  719. supplier,
  720. lineitem,
  721. partsupp,
  722. orders,
  723. nation
  724. WHERE
  725. s_suppkey = l_suppkey
  726. AND ps_suppkey = l_suppkey
  727. AND ps_partkey = l_partkey
  728. AND p_partkey = l_partkey
  729. AND o_orderkey = l_orderkey
  730. AND s_nationkey = n_nationkey
  731. AND p_name like '%green%'
  732. ) AS profit
  733. GROUP BY
  734. nation,
  735. o_year
  736. ORDER BY
  737. nation,
  738. o_year DESC;
  739. query T multiline
  740. -- Explain index on Q09
  741. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  742. CREATE DEFAULT INDEX ON Q09;
  743. ----
  744. materialize.public.q09_primary_idx:
  745. ArrangeBy keys=[[#0{nation}, #1{o_year}]] // { arity: 3 }
  746. ReadGlobalFromSameDataflow materialize.public.q09 // { arity: 3 }
  747. materialize.public.q09:
  748. Reduce group_by=[#5{n_name}, extract_year_d(#4{o_orderdate})] aggregates=[sum(((#1{l_extendedprice} * (1 - #2{l_discount})) - (#3{ps_supplycost} * #0{l_quantity})))] // { arity: 3 }
  749. Project (#20{l_quantity}..=#22{l_discount}, #35{ps_supplycost}, #41{o_orderdate}, #47{n_name}) // { arity: 6 }
  750. Filter like["%green%"](varchar_to_text(#1{p_name})) // { arity: 50 }
  751. Join on=(#0{p_partkey} = #17{l_partkey} = #32{ps_partkey} AND #9{s_suppkey} = #18{l_suppkey} = #33{ps_suppkey} AND #12{s_nationkey} = #46{n_nationkey} AND #16{l_orderkey} = #37{o_orderkey}) type=delta // { arity: 50 }
  752. implementation
  753. %0:part » %2:lineitem[#1{l_partkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA
  754. %1:supplier » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA
  755. %2:lineitem » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA
  756. %3:partsupp » %2:lineitem[#1{l_partkey}, #2{l_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %4:orders[#0{o_orderkey}]KA » %5:nation[#0{n_nationkey}]KA
  757. %4:orders » %2:lineitem[#0{l_orderkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %1:supplier[#0{s_suppkey}]KA » %5:nation[#0{n_nationkey}]KA
  758. %5:nation » %1:supplier[#3{s_nationkey}]KA » %2:lineitem[#2{l_suppkey}]KA » %3:partsupp[#0{ps_partkey}, #1{ps_suppkey}]KKA » %0:part[#0{p_partkey}]KAlf » %4:orders[#0{o_orderkey}]KA
  759. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  760. ReadIndex on=part pk_part_partkey=[delta join 1st input (full scan)] // { arity: 9 }
  761. ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 }
  762. ReadIndex on=supplier pk_supplier_suppkey=[delta join lookup] fk_supplier_nationkey=[delta join lookup] // { arity: 7 }
  763. ArrangeBy keys=[[#0{l_orderkey}], [#1{l_partkey}], [#1{l_partkey}, #2{l_suppkey}], [#2{l_suppkey}]] // { arity: 16 }
  764. ReadIndex on=lineitem fk_lineitem_orderkey=[delta join lookup] fk_lineitem_partkey=[delta join lookup] fk_lineitem_suppkey=[delta join lookup] fk_lineitem_partsuppkey=[delta join lookup] // { arity: 16 }
  765. ArrangeBy keys=[[#0{ps_partkey}, #1{ps_suppkey}]] // { arity: 5 }
  766. ReadIndex on=partsupp pk_partsupp_partkey_suppkey=[delta join lookup] // { arity: 5 }
  767. ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 }
  768. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] // { arity: 9 }
  769. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  770. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] // { arity: 4 }
  771. Used Indexes:
  772. - materialize.public.pk_nation_nationkey (delta join lookup)
  773. - materialize.public.pk_part_partkey (delta join 1st input (full scan))
  774. - materialize.public.pk_supplier_suppkey (delta join lookup)
  775. - materialize.public.fk_supplier_nationkey (delta join lookup)
  776. - materialize.public.pk_partsupp_partkey_suppkey (delta join lookup)
  777. - materialize.public.pk_orders_orderkey (delta join lookup)
  778. - materialize.public.fk_lineitem_orderkey (delta join lookup)
  779. - materialize.public.fk_lineitem_partkey (delta join lookup)
  780. - materialize.public.fk_lineitem_suppkey (delta join lookup)
  781. - materialize.public.fk_lineitem_partsuppkey (delta join lookup)
  782. Target cluster: quickstart
  783. EOF
  784. statement ok
  785. -- Query 10
  786. CREATE VIEW Q10 AS
  787. SELECT
  788. c_custkey,
  789. c_name,
  790. sum(l_extendedprice * (1 - l_discount)) AS revenue,
  791. c_acctbal,
  792. n_name,
  793. c_address,
  794. c_phone,
  795. c_comment
  796. FROM
  797. customer,
  798. orders,
  799. lineitem,
  800. nation
  801. WHERE
  802. c_custkey = o_custkey
  803. AND l_orderkey = o_orderkey
  804. AND o_orderdate >= DATE '1993-10-01'
  805. AND o_orderdate < DATE '1994-01-01'
  806. AND o_orderdate < DATE '1993-10-01' + INTERVAL '3' month
  807. AND l_returnflag = 'R'
  808. AND c_nationkey = n_nationkey
  809. GROUP BY
  810. c_custkey,
  811. c_name,
  812. c_acctbal,
  813. c_phone,
  814. n_name,
  815. c_address,
  816. c_comment
  817. ORDER BY
  818. revenue DESC;
  819. query T multiline
  820. -- Explain index on Q10
  821. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  822. CREATE DEFAULT INDEX ON Q10;
  823. ----
  824. materialize.public.q10_primary_idx:
  825. ArrangeBy keys=[[#0{c_custkey}, #1{c_name}, #3{c_acctbal}..=#7{c_comment}]] // { arity: 8 }
  826. ReadGlobalFromSameDataflow materialize.public.q10 // { arity: 8 }
  827. materialize.public.q10:
  828. Project (#0{c_custkey}, #1{c_name}, #7{sum}, #2{c_acctbal}, #4{n_name}, #5{c_address}, #3{c_phone}, #6{c_comment}) // { arity: 8 }
  829. Reduce group_by=[#0{c_custkey}, #1{c_name}, #4{c_acctbal}, #3{c_phone}, #8{n_name}, #2{c_address}, #5{c_comment}] aggregates=[sum((#6{l_extendedprice} * (1 - #7{l_discount})))] // { arity: 8 }
  830. Project (#0{c_custkey}..=#2{c_address}, #4{c_phone}, #5{c_acctbal}, #7{c_comment}, #22{l_extendedprice}, #23{l_discount}, #34{n_name}) // { arity: 9 }
  831. Filter (#25{l_returnflag} = "R") AND (#12{o_orderdate} < 1994-01-01) AND (#12{o_orderdate} >= 1993-10-01) AND (date_to_timestamp(#12{o_orderdate}) < 1994-01-01 00:00:00) // { arity: 37 }
  832. Join on=(#0{c_custkey} = #9{o_custkey} AND #3{c_nationkey} = #33{n_nationkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 37 }
  833. implementation
  834. %0:customer » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef » %3:nation[#0{n_nationkey}]KA
  835. %1:orders » %2:lineitem[#0{l_orderkey}]KAef » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA
  836. %2:lineitem » %1:orders[#0{o_orderkey}]KAiiif » %0:customer[#0{c_custkey}]KA » %3:nation[#0{n_nationkey}]KA
  837. %3:nation » %0:customer[#3{c_nationkey}]KA » %1:orders[#1{o_custkey}]KAiiif » %2:lineitem[#0{l_orderkey}]KAef
  838. ArrangeBy keys=[[#0{c_custkey}], [#3{c_nationkey}]] // { arity: 8 }
  839. ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] fk_customer_nationkey=[delta join lookup] // { arity: 8 }
  840. ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 }
  841. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] fk_orders_custkey=[delta join lookup] // { arity: 9 }
  842. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 }
  843. ReadIndex on=lineitem fk_lineitem_orderkey=[delta join lookup] // { arity: 16 }
  844. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  845. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] // { arity: 4 }
  846. Used Indexes:
  847. - materialize.public.pk_nation_nationkey (delta join lookup)
  848. - materialize.public.pk_customer_custkey (delta join 1st input (full scan))
  849. - materialize.public.fk_customer_nationkey (delta join lookup)
  850. - materialize.public.pk_orders_orderkey (delta join lookup)
  851. - materialize.public.fk_orders_custkey (delta join lookup)
  852. - materialize.public.fk_lineitem_orderkey (delta join lookup)
  853. Target cluster: quickstart
  854. EOF
  855. statement ok
  856. -- Query 11
  857. CREATE VIEW Q11 AS
  858. SELECT
  859. ps_partkey,
  860. sum(ps_supplycost * ps_availqty) AS value
  861. FROM
  862. partsupp,
  863. supplier,
  864. nation
  865. WHERE
  866. ps_suppkey = s_suppkey
  867. AND s_nationkey = n_nationkey
  868. AND n_name = 'GERMANY'
  869. GROUP BY
  870. ps_partkey having
  871. sum(ps_supplycost * ps_availqty) > (
  872. SELECT
  873. sum(ps_supplycost * ps_availqty) * 0.0001
  874. FROM
  875. partsupp,
  876. supplier,
  877. nation
  878. WHERE
  879. ps_suppkey = s_suppkey
  880. AND s_nationkey = n_nationkey
  881. AND n_name = 'GERMANY'
  882. )
  883. ORDER BY
  884. value DESC;
  885. query T multiline
  886. -- Explain index on Q11
  887. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  888. CREATE DEFAULT INDEX ON Q11;
  889. ----
  890. materialize.public.q11_primary_idx:
  891. ArrangeBy keys=[[#0{ps_partkey}]] // { arity: 2 }
  892. ReadGlobalFromSameDataflow materialize.public.q11 // { arity: 2 }
  893. materialize.public.q11:
  894. With
  895. cte l0 =
  896. Project (#0{ps_partkey}, #2{ps_availqty}, #3{ps_supplycost}) // { arity: 3 }
  897. Filter (#13{n_name} = "GERMANY") // { arity: 16 }
  898. Join on=(#1{ps_suppkey} = #5{s_suppkey} AND #8{s_nationkey} = #12{n_nationkey}) type=delta // { arity: 16 }
  899. implementation
  900. %0:partsupp » %1:supplier[#0{s_suppkey}]KA » %2:nation[#0{n_nationkey}]KAef
  901. %1:supplier » %2:nation[#0{n_nationkey}]KAef » %0:partsupp[#1{ps_suppkey}]KA
  902. %2:nation » %1:supplier[#3{s_nationkey}]KA » %0:partsupp[#1{ps_suppkey}]KA
  903. ArrangeBy keys=[[#1{ps_suppkey}]] // { arity: 5 }
  904. ReadIndex on=partsupp fk_partsupp_suppkey=[delta join 1st input (full scan)] // { arity: 5 }
  905. ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 }
  906. ReadIndex on=supplier pk_supplier_suppkey=[delta join lookup] fk_supplier_nationkey=[delta join lookup] // { arity: 7 }
  907. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  908. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] // { arity: 4 }
  909. Return // { arity: 2 }
  910. Project (#0{ps_partkey}, #1{sum}) // { arity: 2 }
  911. Filter (#1{sum} > (#2{sum} * 0.0001)) // { arity: 3 }
  912. CrossJoin type=differential // { arity: 3 }
  913. implementation
  914. %1[×]UA » %0[×]
  915. ArrangeBy keys=[[]] // { arity: 2 }
  916. Reduce group_by=[#0{ps_partkey}] aggregates=[sum((#2{ps_supplycost} * integer_to_numeric(#1{ps_availqty})))] // { arity: 2 }
  917. Get l0 // { arity: 3 }
  918. ArrangeBy keys=[[]] // { arity: 1 }
  919. Reduce aggregates=[sum((#1{ps_supplycost} * integer_to_numeric(#0{ps_availqty})))] // { arity: 1 }
  920. Project (#1{ps_availqty}, #2{ps_supplycost}) // { arity: 2 }
  921. Get l0 // { arity: 3 }
  922. Used Indexes:
  923. - materialize.public.pk_nation_nationkey (delta join lookup)
  924. - materialize.public.pk_supplier_suppkey (delta join lookup)
  925. - materialize.public.fk_supplier_nationkey (delta join lookup)
  926. - materialize.public.fk_partsupp_suppkey (delta join 1st input (full scan))
  927. Target cluster: quickstart
  928. EOF
  929. statement ok
  930. -- Query 12
  931. CREATE VIEW Q12 AS
  932. SELECT
  933. l_shipmode,
  934. sum(case
  935. when o_orderpriority = '1-URGENT'
  936. or o_orderpriority = '2-HIGH'
  937. then 1
  938. else 0
  939. end) AS high_line_count,
  940. sum(case
  941. when o_orderpriority <> '1-URGENT'
  942. AND o_orderpriority <> '2-HIGH'
  943. then 1
  944. else 0
  945. end) AS low_line_count
  946. FROM
  947. orders,
  948. lineitem
  949. WHERE
  950. o_orderkey = l_orderkey
  951. AND l_shipmode IN ('MAIL', 'SHIP')
  952. AND l_commitdate < l_receiptdate
  953. AND l_shipdate < l_commitdate
  954. AND l_receiptdate >= DATE '1994-01-01'
  955. AND l_receiptdate < DATE '1994-01-01' + INTERVAL '1' year
  956. GROUP BY
  957. l_shipmode
  958. ORDER BY
  959. l_shipmode;
  960. query T multiline
  961. -- Explain index on Q12
  962. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  963. CREATE DEFAULT INDEX ON Q12;
  964. ----
  965. materialize.public.q12_primary_idx:
  966. ArrangeBy keys=[[#0{l_shipmode}]] // { arity: 3 }
  967. ReadGlobalFromSameDataflow materialize.public.q12 // { arity: 3 }
  968. materialize.public.q12:
  969. Reduce group_by=[#1{l_shipmode}] aggregates=[sum(case when ((#0{o_orderpriority} = "2-HIGH") OR (#0{o_orderpriority} = "1-URGENT")) then 1 else 0 end), sum(case when ((#0{o_orderpriority} != "2-HIGH") AND (#0{o_orderpriority} != "1-URGENT")) then 1 else 0 end)] // { arity: 3 }
  970. Project (#5{o_orderpriority}, #23{l_shipmode}) // { arity: 2 }
  971. Filter (#21{l_receiptdate} >= 1994-01-01) AND (#19{l_shipdate} < #20{l_commitdate}) AND (#20{l_commitdate} < #21{l_receiptdate}) AND (date_to_timestamp(#21{l_receiptdate}) < 1995-01-01 00:00:00) AND ((#23{l_shipmode} = "MAIL") OR (#23{l_shipmode} = "SHIP")) // { arity: 25 }
  972. Join on=(#0{o_orderkey} = #9{l_orderkey}) type=differential // { arity: 25 }
  973. implementation
  974. %1:lineitem[#0{l_orderkey}]KAeiif » %0:orders[#0{o_orderkey}]KAeiif
  975. ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 }
  976. ReadIndex on=orders pk_orders_orderkey=[differential join] // { arity: 9 }
  977. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 }
  978. ReadIndex on=lineitem fk_lineitem_orderkey=[differential join] // { arity: 16 }
  979. Used Indexes:
  980. - materialize.public.pk_orders_orderkey (differential join)
  981. - materialize.public.fk_lineitem_orderkey (differential join)
  982. Target cluster: quickstart
  983. EOF
  984. statement ok
  985. -- Query 13
  986. CREATE VIEW Q13 AS
  987. SELECT
  988. c_count,
  989. count(*) AS custdist
  990. FROM
  991. (
  992. SELECT
  993. c_custkey,
  994. count(o_orderkey) c_count -- workaround for no column aliases
  995. FROM
  996. customer LEFT OUTER JOIN orders ON
  997. c_custkey = o_custkey
  998. AND o_comment NOT LIKE '%special%requests%'
  999. GROUP BY
  1000. c_custkey
  1001. ) AS c_orders -- (c_custkey, c_count) -- no column aliases yet
  1002. GROUP BY
  1003. c_count
  1004. ORDER BY
  1005. custdist DESC,
  1006. c_count DESC;
  1007. query T multiline
  1008. -- Explain index on Q13
  1009. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1010. CREATE DEFAULT INDEX ON Q13;
  1011. ----
  1012. materialize.public.q13_primary_idx:
  1013. ArrangeBy keys=[[#0{c_count}]] // { arity: 2 }
  1014. ReadGlobalFromSameDataflow materialize.public.q13 // { arity: 2 }
  1015. materialize.public.q13:
  1016. With
  1017. cte l0 =
  1018. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 }
  1019. ReadIndex on=customer pk_customer_custkey=[differential join] // { arity: 8 }
  1020. cte l1 =
  1021. Project (#0{c_custkey}, #8{o_orderkey}) // { arity: 2 }
  1022. Filter NOT(like["%special%requests%"](varchar_to_text(#16{o_comment}))) // { arity: 17 }
  1023. Join on=(#0{c_custkey} = #9{o_custkey}) type=differential // { arity: 17 }
  1024. implementation
  1025. %1:orders[#1{o_custkey}]KAf » %0:l0[#0{c_custkey}]KAf
  1026. Get l0 // { arity: 8 }
  1027. ArrangeBy keys=[[#1{o_custkey}]] // { arity: 9 }
  1028. ReadIndex on=orders fk_orders_custkey=[differential join] // { arity: 9 }
  1029. Return // { arity: 2 }
  1030. Reduce group_by=[#0{count_o_orderkey}] aggregates=[count(*)] // { arity: 2 }
  1031. Project (#1{count_o_orderkey}) // { arity: 1 }
  1032. Reduce group_by=[#0{c_custkey}] aggregates=[count(#1{o_orderkey})] // { arity: 2 }
  1033. Union // { arity: 2 }
  1034. Map (null) // { arity: 2 }
  1035. Union // { arity: 1 }
  1036. Negate // { arity: 1 }
  1037. Project (#0{c_custkey}) // { arity: 1 }
  1038. Join on=(#0{c_custkey} = #8{c_custkey}) type=differential // { arity: 9 }
  1039. implementation
  1040. %1[#0]UKA » %0:l0[#0{c_custkey}]KA
  1041. Get l0 // { arity: 8 }
  1042. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 1 }
  1043. Distinct project=[#0{c_custkey}] // { arity: 1 }
  1044. Project (#0{c_custkey}) // { arity: 1 }
  1045. Get l1 // { arity: 2 }
  1046. Project (#0{c_custkey}) // { arity: 1 }
  1047. ReadIndex on=customer pk_customer_custkey=[*** full scan ***] // { arity: 8 }
  1048. Get l1 // { arity: 2 }
  1049. Used Indexes:
  1050. - materialize.public.pk_customer_custkey (*** full scan ***, differential join)
  1051. - materialize.public.fk_orders_custkey (differential join)
  1052. Target cluster: quickstart
  1053. EOF
  1054. statement ok
  1055. -- Query 14
  1056. CREATE VIEW Q14 AS
  1057. SELECT
  1058. 100.00 * sum(case
  1059. when p_type like 'PROMO%'
  1060. then l_extendedprice * (1 - l_discount)
  1061. else 0
  1062. end) / sum(l_extendedprice * (1 - l_discount)) AS promo_revenue
  1063. FROM
  1064. lineitem,
  1065. part
  1066. WHERE
  1067. l_partkey = p_partkey
  1068. AND l_shipdate >= DATE '1995-09-01'
  1069. AND l_shipdate < DATE '1995-09-01' + INTERVAL '1' month;
  1070. query T multiline
  1071. -- Explain index on Q14
  1072. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1073. CREATE DEFAULT INDEX ON Q14;
  1074. ----
  1075. materialize.public.q14_primary_idx:
  1076. ArrangeBy keys=[[#0{promo_revenue}]] // { arity: 1 }
  1077. ReadGlobalFromSameDataflow materialize.public.q14 // { arity: 1 }
  1078. materialize.public.q14:
  1079. With
  1080. cte l0 =
  1081. Reduce aggregates=[sum(case when like["PROMO%"](varchar_to_text(#2{p_type})) then (#0{l_extendedprice} * (1 - #1{l_discount})) else 0 end), sum((#0{l_extendedprice} * (1 - #1{l_discount})))] // { arity: 2 }
  1082. Project (#5{l_extendedprice}, #6{l_discount}, #20{p_type}) // { arity: 3 }
  1083. Filter (#10{l_shipdate} >= 1995-09-01) AND (date_to_timestamp(#10{l_shipdate}) < 1995-10-01 00:00:00) // { arity: 25 }
  1084. Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 }
  1085. implementation
  1086. %0:lineitem[#1{l_partkey}]KAiif » %1:part[#0{p_partkey}]KAiif
  1087. ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 }
  1088. ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 }
  1089. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  1090. ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 }
  1091. Return // { arity: 1 }
  1092. Project (#2) // { arity: 1 }
  1093. Map (((100 * #0{sum}) / #1{sum})) // { arity: 3 }
  1094. Union // { arity: 2 }
  1095. Get l0 // { arity: 2 }
  1096. Map (null, null) // { arity: 2 }
  1097. Union // { arity: 0 }
  1098. Negate // { arity: 0 }
  1099. Project () // { arity: 0 }
  1100. Get l0 // { arity: 2 }
  1101. Constant // { arity: 0 }
  1102. - ()
  1103. Used Indexes:
  1104. - materialize.public.pk_part_partkey (differential join)
  1105. - materialize.public.fk_lineitem_partkey (differential join)
  1106. Target cluster: quickstart
  1107. EOF
  1108. statement ok
  1109. create view revenue (supplier_no, total_revenue) as
  1110. SELECT
  1111. l_suppkey,
  1112. sum(l_extendedprice * (1 - l_discount))
  1113. FROM
  1114. lineitem
  1115. WHERE
  1116. l_shipdate >= DATE '1996-01-01'
  1117. AND l_shipdate < DATE '1996-01-01' + INTERVAL '3' month
  1118. GROUP BY
  1119. l_suppkey
  1120. statement ok
  1121. -- Query 15
  1122. CREATE VIEW Q15 AS
  1123. SELECT
  1124. s_suppkey,
  1125. s_name,
  1126. s_address,
  1127. s_phone,
  1128. total_revenue
  1129. FROM
  1130. supplier,
  1131. revenue
  1132. WHERE
  1133. s_suppkey = supplier_no
  1134. AND total_revenue = (
  1135. SELECT
  1136. max(total_revenue)
  1137. FROM
  1138. revenue
  1139. )
  1140. ORDER BY
  1141. s_suppkey;
  1142. query T multiline
  1143. -- Explain index on Q15
  1144. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1145. CREATE DEFAULT INDEX ON Q15;
  1146. ----
  1147. materialize.public.q15_primary_idx:
  1148. ArrangeBy keys=[[#0{s_suppkey}..=#4{total_revenue}]] // { arity: 5 }
  1149. ReadGlobalFromSameDataflow materialize.public.q15 // { arity: 5 }
  1150. materialize.public.q15:
  1151. With
  1152. cte l0 =
  1153. Reduce group_by=[#0{l_suppkey}] aggregates=[sum((#1{l_extendedprice} * (1 - #2{l_discount})))] // { arity: 2 }
  1154. Project (#2{l_suppkey}, #5{l_extendedprice}, #6{l_discount}) // { arity: 3 }
  1155. Filter (#10{l_shipdate} >= 1996-01-01) AND (date_to_timestamp(#10{l_shipdate}) < 1996-04-01 00:00:00) // { arity: 16 }
  1156. ReadIndex on=lineitem pk_lineitem_orderkey_linenumber=[*** full scan ***] // { arity: 16 }
  1157. Return // { arity: 5 }
  1158. Project (#0{s_suppkey}..=#2{s_address}, #4{s_phone}, #8{sum}) // { arity: 5 }
  1159. Join on=(#0{s_suppkey} = #7{l_suppkey} AND #8{sum} = #9{max_sum}) type=delta // { arity: 10 }
  1160. implementation
  1161. %0:supplier » %1:l0[#0]UKA » %2[#0]UK
  1162. %1:l0 » %2[#0]UK » %0:supplier[#0{s_suppkey}]KA
  1163. %2 » %1:l0[#1{total_revenue}]K » %0:supplier[#0{s_suppkey}]KA
  1164. ArrangeBy keys=[[#0{s_suppkey}]] // { arity: 7 }
  1165. ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] // { arity: 7 }
  1166. ArrangeBy keys=[[#0{l_suppkey}], [#1{sum}]] // { arity: 2 }
  1167. Get l0 // { arity: 2 }
  1168. ArrangeBy keys=[[#0{max_sum}]] // { arity: 1 }
  1169. Reduce aggregates=[max(#0{sum})] // { arity: 1 }
  1170. Project (#1{sum}) // { arity: 1 }
  1171. Get l0 // { arity: 2 }
  1172. Used Indexes:
  1173. - materialize.public.pk_supplier_suppkey (delta join 1st input (full scan))
  1174. - materialize.public.pk_lineitem_orderkey_linenumber (*** full scan ***)
  1175. Target cluster: quickstart
  1176. EOF
  1177. statement ok
  1178. -- Query 16
  1179. CREATE VIEW Q16 AS
  1180. SELECT
  1181. p_brand,
  1182. p_type,
  1183. p_size,
  1184. count(DISTINCT ps_suppkey) AS supplier_cnt
  1185. FROM
  1186. partsupp,
  1187. part
  1188. WHERE
  1189. p_partkey = ps_partkey
  1190. AND p_brand <> 'Brand#45'
  1191. AND p_type NOT LIKE 'MEDIUM POLISHED%'
  1192. AND p_size IN (49, 14, 23, 45, 19, 3, 36, 9)
  1193. AND ps_suppkey NOT IN (
  1194. SELECT
  1195. s_suppkey
  1196. FROM
  1197. supplier
  1198. WHERE
  1199. s_comment like '%Customer%Complaints%'
  1200. )
  1201. GROUP BY
  1202. p_brand,
  1203. p_type,
  1204. p_size
  1205. ORDER BY
  1206. supplier_cnt DESC,
  1207. p_brand,
  1208. p_type,
  1209. p_size;
  1210. query T multiline
  1211. -- Explain index on Q16
  1212. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1213. CREATE DEFAULT INDEX ON Q16;
  1214. ----
  1215. materialize.public.q16_primary_idx:
  1216. ArrangeBy keys=[[#0{p_brand}..=#2{p_size}]] // { arity: 4 }
  1217. ReadGlobalFromSameDataflow materialize.public.q16 // { arity: 4 }
  1218. materialize.public.q16:
  1219. With
  1220. cte l0 =
  1221. Project (#1{ps_suppkey}, #8{p_brand}..=#10{p_size}) // { arity: 4 }
  1222. Filter (#8{p_brand} != "Brand#45") AND NOT(like["MEDIUM POLISHED%"](varchar_to_text(#9{p_type}))) AND ((#10{p_size} = 3) OR (#10{p_size} = 9) OR (#10{p_size} = 14) OR (#10{p_size} = 19) OR (#10{p_size} = 23) OR (#10{p_size} = 36) OR (#10{p_size} = 45) OR (#10{p_size} = 49)) // { arity: 14 }
  1223. Join on=(#0{ps_partkey} = #5{p_partkey}) type=differential // { arity: 14 }
  1224. implementation
  1225. %1:part[#0{p_partkey}]KAef » %0:partsupp[#0{ps_partkey}]KAef
  1226. ArrangeBy keys=[[#0{ps_partkey}]] // { arity: 5 }
  1227. ReadIndex on=partsupp fk_partsupp_partkey=[differential join] // { arity: 5 }
  1228. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  1229. ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 }
  1230. cte l1 =
  1231. Distinct project=[#0{ps_suppkey}] // { arity: 1 }
  1232. Project (#0{ps_suppkey}) // { arity: 1 }
  1233. Get l0 // { arity: 4 }
  1234. Return // { arity: 4 }
  1235. Reduce group_by=[#1{p_brand}..=#3{p_size}] aggregates=[count(distinct #0{ps_suppkey})] // { arity: 4 }
  1236. Project (#0{ps_suppkey}..=#3{p_size}) // { arity: 4 }
  1237. Join on=(#0{ps_suppkey} = #4{ps_suppkey}) type=differential // { arity: 5 }
  1238. implementation
  1239. %0:l0[#0]K » %1[#0]K
  1240. ArrangeBy keys=[[#0{ps_suppkey}]] // { arity: 4 }
  1241. Get l0 // { arity: 4 }
  1242. ArrangeBy keys=[[#0{ps_suppkey}]] // { arity: 1 }
  1243. Union // { arity: 1 }
  1244. Negate // { arity: 1 }
  1245. Distinct project=[#0{ps_suppkey}] // { arity: 1 }
  1246. Project (#0{ps_suppkey}) // { arity: 1 }
  1247. Filter ((#1{s_suppkey}) IS NULL OR (#0{ps_suppkey} = #1{s_suppkey})) // { arity: 2 }
  1248. CrossJoin type=differential // { arity: 2 }
  1249. implementation
  1250. %1:supplier[×]lf » %0:l1[×]lf
  1251. ArrangeBy keys=[[]] // { arity: 1 }
  1252. Get l1 // { arity: 1 }
  1253. ArrangeBy keys=[[]] // { arity: 1 }
  1254. Project (#0{s_suppkey}) // { arity: 1 }
  1255. Filter like["%Customer%Complaints%"](varchar_to_text(#6{s_comment})) // { arity: 7 }
  1256. ReadIndex on=supplier pk_supplier_suppkey=[*** full scan ***] // { arity: 7 }
  1257. Get l1 // { arity: 1 }
  1258. Used Indexes:
  1259. - materialize.public.pk_part_partkey (differential join)
  1260. - materialize.public.pk_supplier_suppkey (*** full scan ***)
  1261. - materialize.public.fk_partsupp_partkey (differential join)
  1262. Target cluster: quickstart
  1263. EOF
  1264. statement ok
  1265. -- Query 17
  1266. CREATE VIEW Q17 AS
  1267. SELECT
  1268. sum(l_extendedprice) / 7.0 AS avg_yearly
  1269. FROM
  1270. lineitem,
  1271. part
  1272. WHERE
  1273. p_partkey = l_partkey
  1274. AND p_brand = 'Brand#23'
  1275. AND p_container = 'MED BOX'
  1276. AND l_quantity < (
  1277. SELECT
  1278. 0.2 * avg(l_quantity)
  1279. FROM
  1280. lineitem
  1281. WHERE
  1282. l_partkey = p_partkey
  1283. );
  1284. query T multiline
  1285. -- Explain index on Q17
  1286. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1287. CREATE DEFAULT INDEX ON Q17;
  1288. ----
  1289. materialize.public.q17_primary_idx:
  1290. ArrangeBy keys=[[#0{avg_yearly}]] // { arity: 1 }
  1291. ReadGlobalFromSameDataflow materialize.public.q17 // { arity: 1 }
  1292. materialize.public.q17:
  1293. With
  1294. cte l0 =
  1295. ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 }
  1296. ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 }
  1297. cte l1 =
  1298. Project (#1{l_partkey}, #4{l_quantity}, #5{l_extendedprice}) // { arity: 3 }
  1299. Filter (#19{p_brand} = "Brand#23") AND (#22{p_container} = "MED BOX") // { arity: 25 }
  1300. Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 }
  1301. implementation
  1302. %1:part[#0{p_partkey}]KAef » %0:l0[#1{l_partkey}]KAef
  1303. Get l0 // { arity: 16 }
  1304. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  1305. ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 }
  1306. cte l2 =
  1307. Reduce aggregates=[sum(#0{l_extendedprice})] // { arity: 1 }
  1308. Project (#2{l_extendedprice}) // { arity: 1 }
  1309. Filter (#1{l_quantity} < (0.2 * (#4{sum_l_quantity} / bigint_to_numeric(case when (#5{count} = 0) then null else #5{count} end)))) // { arity: 6 }
  1310. Join on=(#0{l_partkey} = #3{l_partkey}) type=differential // { arity: 6 }
  1311. implementation
  1312. %1[#0]UKA » %0:l1[#0]K
  1313. ArrangeBy keys=[[#0{l_partkey}]] // { arity: 3 }
  1314. Get l1 // { arity: 3 }
  1315. ArrangeBy keys=[[#0{l_partkey}]] // { arity: 3 }
  1316. Reduce group_by=[#0{l_partkey}] aggregates=[sum(#1{l_quantity}), count(*)] // { arity: 3 }
  1317. Project (#0{l_partkey}, #5{l_quantity}) // { arity: 2 }
  1318. Join on=(#0{l_partkey} = #2{l_partkey}) type=differential // { arity: 17 }
  1319. implementation
  1320. %0[#0{p_partkey}]UKA » %1:l0[#1{l_partkey}]KA
  1321. ArrangeBy keys=[[#0{l_partkey}]] // { arity: 1 }
  1322. Distinct project=[#0{l_partkey}] // { arity: 1 }
  1323. Project (#0{l_partkey}) // { arity: 1 }
  1324. Get l1 // { arity: 3 }
  1325. Get l0 // { arity: 16 }
  1326. Return // { arity: 1 }
  1327. Project (#1) // { arity: 1 }
  1328. Map ((#0{sum_l_extendedprice} / 7)) // { arity: 2 }
  1329. Union // { arity: 1 }
  1330. Get l2 // { arity: 1 }
  1331. Map (null) // { arity: 1 }
  1332. Union // { arity: 0 }
  1333. Negate // { arity: 0 }
  1334. Project () // { arity: 0 }
  1335. Get l2 // { arity: 1 }
  1336. Constant // { arity: 0 }
  1337. - ()
  1338. Used Indexes:
  1339. - materialize.public.pk_part_partkey (differential join)
  1340. - materialize.public.fk_lineitem_partkey (differential join)
  1341. Target cluster: quickstart
  1342. EOF
  1343. statement ok
  1344. -- Query 18
  1345. CREATE VIEW Q18 AS
  1346. SELECT
  1347. c_name,
  1348. c_custkey,
  1349. o_orderkey,
  1350. o_orderdate,
  1351. o_totalprice,
  1352. sum(l_quantity)
  1353. FROM
  1354. customer,
  1355. orders,
  1356. lineitem
  1357. WHERE
  1358. o_orderkey IN (
  1359. SELECT
  1360. l_orderkey
  1361. FROM
  1362. lineitem
  1363. GROUP BY
  1364. l_orderkey having
  1365. sum(l_quantity) > 300
  1366. )
  1367. AND c_custkey = o_custkey
  1368. AND o_orderkey = l_orderkey
  1369. GROUP BY
  1370. c_name,
  1371. c_custkey,
  1372. o_orderkey,
  1373. o_orderdate,
  1374. o_totalprice
  1375. ORDER BY
  1376. o_totalprice DESC,
  1377. o_orderdate;
  1378. query T multiline
  1379. -- Explain index on Q18
  1380. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1381. CREATE DEFAULT INDEX ON Q18;
  1382. ----
  1383. materialize.public.q18_primary_idx:
  1384. ArrangeBy keys=[[#0{c_name}..=#4{o_totalprice}]] // { arity: 6 }
  1385. ReadGlobalFromSameDataflow materialize.public.q18 // { arity: 6 }
  1386. materialize.public.q18:
  1387. With
  1388. cte l0 =
  1389. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 }
  1390. ReadIndex on=lineitem fk_lineitem_orderkey=[differential join, delta join lookup] // { arity: 16 }
  1391. cte l1 =
  1392. Project (#0{c_custkey}, #1{c_name}, #8{o_orderkey}, #11{o_totalprice}, #12{o_orderdate}, #21{l_quantity}) // { arity: 6 }
  1393. Join on=(#0{c_custkey} = #9{o_custkey} AND #8{o_orderkey} = #17{l_orderkey}) type=delta // { arity: 33 }
  1394. implementation
  1395. %0:customer » %1:orders[#1{o_custkey}]KA » %2:l0[#0{l_orderkey}]KA
  1396. %1:orders » %0:customer[#0{c_custkey}]KA » %2:l0[#0{l_orderkey}]KA
  1397. %2:l0 » %1:orders[#0{o_orderkey}]KA » %0:customer[#0{c_custkey}]KA
  1398. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 8 }
  1399. ReadIndex on=customer pk_customer_custkey=[delta join 1st input (full scan)] // { arity: 8 }
  1400. ArrangeBy keys=[[#0{o_orderkey}], [#1{o_custkey}]] // { arity: 9 }
  1401. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] fk_orders_custkey=[delta join lookup] // { arity: 9 }
  1402. Get l0 // { arity: 16 }
  1403. Return // { arity: 6 }
  1404. Reduce group_by=[#1{c_name}, #0{c_custkey}, #2{o_orderkey}, #4{o_orderdate}, #3{o_totalprice}] aggregates=[sum(#5{l_quantity})] // { arity: 6 }
  1405. Project (#0{c_custkey}..=#5{l_quantity}) // { arity: 6 }
  1406. Filter (#7{sum_l_quantity} > 300) // { arity: 8 }
  1407. Join on=(#2{o_orderkey} = #6{o_orderkey}) type=differential // { arity: 8 }
  1408. implementation
  1409. %1[#0]UKAif » %0:l1[#2]Kif
  1410. ArrangeBy keys=[[#2{o_orderkey}]] // { arity: 6 }
  1411. Get l1 // { arity: 6 }
  1412. ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 2 }
  1413. Reduce group_by=[#0{o_orderkey}] aggregates=[sum(#1{l_quantity})] // { arity: 2 }
  1414. Project (#0{o_orderkey}, #5{l_quantity}) // { arity: 2 }
  1415. Join on=(#0{o_orderkey} = #1{l_orderkey}) type=differential // { arity: 17 }
  1416. implementation
  1417. %0[#0]UKA » %1:l0[#0{l_orderkey}]KA
  1418. ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 1 }
  1419. Distinct project=[#0{o_orderkey}] // { arity: 1 }
  1420. Project (#2{o_orderkey}) // { arity: 1 }
  1421. Get l1 // { arity: 6 }
  1422. Get l0 // { arity: 16 }
  1423. Used Indexes:
  1424. - materialize.public.pk_customer_custkey (delta join 1st input (full scan))
  1425. - materialize.public.pk_orders_orderkey (delta join lookup)
  1426. - materialize.public.fk_orders_custkey (delta join lookup)
  1427. - materialize.public.fk_lineitem_orderkey (differential join, delta join lookup)
  1428. Target cluster: quickstart
  1429. EOF
  1430. statement ok
  1431. -- Query 19
  1432. CREATE VIEW Q19 AS
  1433. SELECT
  1434. sum(l_extendedprice* (1 - l_discount)) AS revenue
  1435. FROM
  1436. lineitem,
  1437. part
  1438. WHERE
  1439. (
  1440. p_partkey = l_partkey
  1441. AND p_brand = 'Brand#12'
  1442. AND p_container IN ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
  1443. AND l_quantity >= CAST (1 AS smallint) AND l_quantity <= CAST (1 + 10 AS smallint)
  1444. AND p_size BETWEEN CAST (1 AS smallint) AND CAST (5 AS smallint)
  1445. AND l_shipmode IN ('AIR', 'AIR REG')
  1446. AND l_shipinstruct = 'DELIVER IN PERSON'
  1447. )
  1448. or
  1449. (
  1450. p_partkey = l_partkey
  1451. AND p_brand = 'Brand#23'
  1452. AND p_container IN ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
  1453. AND l_quantity >= CAST (10 AS smallint) AND l_quantity <= CAST (10 + 10 AS smallint)
  1454. AND p_size BETWEEN CAST (1 AS smallint) AND CAST (10 AS smallint)
  1455. AND l_shipmode IN ('AIR', 'AIR REG')
  1456. AND l_shipinstruct = 'DELIVER IN PERSON'
  1457. )
  1458. or
  1459. (
  1460. p_partkey = l_partkey
  1461. AND p_brand = 'Brand#34'
  1462. AND p_container IN ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
  1463. AND l_quantity >= CAST (20 AS smallint) AND l_quantity <= CAST (20 + 10 AS smallint)
  1464. AND p_size BETWEEN CAST (1 AS smallint) AND CAST (15 AS smallint)
  1465. AND l_shipmode IN ('AIR', 'AIR REG')
  1466. AND l_shipinstruct = 'DELIVER IN PERSON'
  1467. );
  1468. query T multiline
  1469. -- Explain index on Q19
  1470. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1471. CREATE DEFAULT INDEX ON Q19;
  1472. ----
  1473. materialize.public.q19_primary_idx:
  1474. ArrangeBy keys=[[#0{revenue}]] // { arity: 1 }
  1475. ReadGlobalFromSameDataflow materialize.public.q19 // { arity: 1 }
  1476. materialize.public.q19:
  1477. With
  1478. cte l0 =
  1479. Reduce aggregates=[sum((#0{l_extendedprice} * (1 - #1{l_discount})))] // { arity: 1 }
  1480. Project (#5{l_extendedprice}, #6{l_discount}) // { arity: 2 }
  1481. Filter (#13{l_shipinstruct} = "DELIVER IN PERSON") AND (#21{p_size} >= 1) AND ((#14{l_shipmode} = "AIR") OR (#14{l_shipmode} = "AIR REG")) AND ((#25 AND #26) OR (#27 AND #28) OR (#29 AND #30)) AND ((#31 AND #32 AND #33) OR (#34 AND #35 AND #36) OR (#37 AND #38 AND #39)) AND ((#25 AND #26 AND #34 AND #35 AND #36) OR (#27 AND #28 AND #37 AND #38 AND #39) OR (#29 AND #30 AND #31 AND #32 AND #33)) // { arity: 40 }
  1482. Map ((#4{l_quantity} <= 20), (#4{l_quantity} >= 10), (#4{l_quantity} <= 30), (#4{l_quantity} >= 20), (#4{l_quantity} <= 11), (#4{l_quantity} >= 1), (#19{p_brand} = "Brand#12"), (#21{p_size} <= 5), ((#22{p_container} = "SM BOX") OR (#22{p_container} = "SM PKG") OR (#22{p_container} = "SM CASE") OR (#22{p_container} = "SM PACK")), (#19{p_brand} = "Brand#23"), (#21{p_size} <= 10), ((#22{p_container} = "MED BAG") OR (#22{p_container} = "MED BOX") OR (#22{p_container} = "MED PKG") OR (#22{p_container} = "MED PACK")), (#19{p_brand} = "Brand#34"), (#21{p_size} <= 15), ((#22{p_container} = "LG BOX") OR (#22{p_container} = "LG PKG") OR (#22{p_container} = "LG CASE") OR (#22{p_container} = "LG PACK"))) // { arity: 40 }
  1483. Join on=(#1{l_partkey} = #16{p_partkey}) type=differential // { arity: 25 }
  1484. implementation
  1485. %1:part[#0{p_partkey}]KAeiiif » %0:lineitem[#1{l_partkey}]KAeiiiiif
  1486. ArrangeBy keys=[[#1{l_partkey}]] // { arity: 16 }
  1487. ReadIndex on=lineitem fk_lineitem_partkey=[differential join] // { arity: 16 }
  1488. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 9 }
  1489. ReadIndex on=part pk_part_partkey=[differential join] // { arity: 9 }
  1490. Return // { arity: 1 }
  1491. Union // { arity: 1 }
  1492. Get l0 // { arity: 1 }
  1493. Map (null) // { arity: 1 }
  1494. Union // { arity: 0 }
  1495. Negate // { arity: 0 }
  1496. Project () // { arity: 0 }
  1497. Get l0 // { arity: 1 }
  1498. Constant // { arity: 0 }
  1499. - ()
  1500. Used Indexes:
  1501. - materialize.public.pk_part_partkey (differential join)
  1502. - materialize.public.fk_lineitem_partkey (differential join)
  1503. Target cluster: quickstart
  1504. EOF
  1505. statement ok
  1506. -- Query 20
  1507. CREATE VIEW Q20 AS
  1508. SELECT
  1509. s_name,
  1510. s_address
  1511. FROM
  1512. supplier,
  1513. nation
  1514. WHERE
  1515. s_suppkey IN (
  1516. SELECT
  1517. ps_suppkey
  1518. FROM
  1519. partsupp
  1520. WHERE
  1521. ps_partkey IN (
  1522. SELECT
  1523. p_partkey
  1524. FROM
  1525. part
  1526. WHERE
  1527. p_name like 'forest%'
  1528. )
  1529. AND ps_availqty > (
  1530. SELECT
  1531. 0.5 * sum(l_quantity)
  1532. FROM
  1533. lineitem
  1534. WHERE
  1535. l_partkey = ps_partkey
  1536. AND l_suppkey = ps_suppkey
  1537. AND l_shipdate >= DATE '1995-01-01'
  1538. AND l_shipdate < DATE '1995-01-01' + INTERVAL '1' year
  1539. )
  1540. )
  1541. AND s_nationkey = n_nationkey
  1542. AND n_name = 'CANADA'
  1543. ORDER BY
  1544. s_name;
  1545. query T multiline
  1546. -- Explain index on Q20
  1547. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1548. CREATE DEFAULT INDEX ON Q20;
  1549. ----
  1550. materialize.public.q20_primary_idx:
  1551. ArrangeBy keys=[[#0{s_name}, #1{s_address}]] // { arity: 2 }
  1552. ReadGlobalFromSameDataflow materialize.public.q20 // { arity: 2 }
  1553. materialize.public.q20:
  1554. With
  1555. cte l0 =
  1556. Project (#0{s_suppkey}..=#2{s_address}) // { arity: 3 }
  1557. Filter (#8{n_name} = "CANADA") // { arity: 11 }
  1558. Join on=(#3{s_nationkey} = #7{n_nationkey}) type=differential // { arity: 11 }
  1559. implementation
  1560. %1:nation[#0{n_nationkey}]KAef » %0:supplier[#3{s_nationkey}]KAef
  1561. ArrangeBy keys=[[#3{s_nationkey}]] // { arity: 7 }
  1562. ReadIndex on=supplier fk_supplier_nationkey=[differential join] // { arity: 7 }
  1563. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  1564. ReadIndex on=nation pk_nation_nationkey=[differential join] // { arity: 4 }
  1565. cte l1 =
  1566. Project (#0{s_suppkey}..=#3{ps_availqty}) // { arity: 4 }
  1567. Join on=(#1{ps_partkey} = #4{p_partkey}) type=delta // { arity: 5 }
  1568. implementation
  1569. %0 » %1:partsupp[×] » %2[#0]UKA
  1570. %1:partsupp » %2[#0]UKA » %0[×]
  1571. %2 » %1:partsupp[#0{ps_partkey}]KA » %0[×]
  1572. ArrangeBy keys=[[]] // { arity: 1 }
  1573. Distinct project=[#0{s_suppkey}] // { arity: 1 }
  1574. Project (#0{s_suppkey}) // { arity: 1 }
  1575. Get l0 // { arity: 3 }
  1576. ArrangeBy keys=[[], [#0{ps_partkey}]] // { arity: 3 }
  1577. Project (#0{ps_partkey}..=#2{ps_availqty}) // { arity: 3 }
  1578. ReadIndex on=partsupp pk_partsupp_partkey_suppkey=[*** full scan ***] // { arity: 5 }
  1579. ArrangeBy keys=[[#0{p_partkey}]] // { arity: 1 }
  1580. Distinct project=[#0{p_partkey}] // { arity: 1 }
  1581. Project (#0{p_partkey}) // { arity: 1 }
  1582. Filter (#0{p_partkey}) IS NOT NULL AND like["forest%"](varchar_to_text(#1{p_name})) // { arity: 9 }
  1583. ReadIndex on=part pk_part_partkey=[*** full scan ***] // { arity: 9 }
  1584. Return // { arity: 2 }
  1585. Project (#1{s_name}, #2{s_address}) // { arity: 2 }
  1586. Join on=(#0{s_suppkey} = #3{s_suppkey}) type=differential // { arity: 4 }
  1587. implementation
  1588. %1[#0]UKA » %0:l0[#0]K
  1589. ArrangeBy keys=[[#0{s_suppkey}]] // { arity: 3 }
  1590. Get l0 // { arity: 3 }
  1591. ArrangeBy keys=[[#0{s_suppkey}]] // { arity: 1 }
  1592. Distinct project=[#0{s_suppkey}] // { arity: 1 }
  1593. Project (#0{s_suppkey}) // { arity: 1 }
  1594. Filter (integer_to_numeric(#2{ps_availqty}) > #5) // { arity: 6 }
  1595. Join on=(#0{s_suppkey} = #4{ps_suppkey} AND #1{ps_partkey} = #3{ps_partkey}) type=differential // { arity: 6 }
  1596. implementation
  1597. %1[#1, #0]UKK » %0:l1[#0{s_suppkey}, #1]KKf
  1598. ArrangeBy keys=[[#0{s_suppkey}, #1{ps_partkey}]] // { arity: 3 }
  1599. Project (#0{s_suppkey}, #1{ps_partkey}, #3{ps_availqty}) // { arity: 3 }
  1600. Filter (#0{s_suppkey} = #2{ps_suppkey}) // { arity: 4 }
  1601. Get l1 // { arity: 4 }
  1602. ArrangeBy keys=[[#1{ps_suppkey}, #0{ps_partkey}]] // { arity: 3 }
  1603. Project (#0{ps_partkey}, #1{ps_suppkey}, #3) // { arity: 3 }
  1604. Map ((0.5 * #2{sum_l_quantity})) // { arity: 4 }
  1605. Reduce group_by=[#0{ps_partkey}, #1{ps_suppkey}] aggregates=[sum(#2{l_quantity})] // { arity: 3 }
  1606. Project (#0{ps_partkey}, #1{ps_suppkey}, #6{l_quantity}) // { arity: 3 }
  1607. Filter (#12{l_shipdate} >= 1995-01-01) AND (date_to_timestamp(#12{l_shipdate}) < 1996-01-01 00:00:00) // { arity: 18 }
  1608. Join on=(#0{ps_partkey} = #3{l_partkey} AND #1{ps_suppkey} = #4{l_suppkey}) type=differential // { arity: 18 }
  1609. implementation
  1610. %0[#0{ps_partkey}, #1{ps_suppkey}]UKKA » %1:lineitem[#1{l_partkey}, #2{l_suppkey}]KKAiif
  1611. ArrangeBy keys=[[#0{ps_partkey}, #1{ps_suppkey}]] // { arity: 2 }
  1612. Distinct project=[#0{ps_partkey}, #1{ps_suppkey}] // { arity: 2 }
  1613. Project (#1{ps_partkey}, #2{ps_suppkey}) // { arity: 2 }
  1614. Get l1 // { arity: 4 }
  1615. ArrangeBy keys=[[#1{l_partkey}, #2{l_suppkey}]] // { arity: 16 }
  1616. ReadIndex on=lineitem fk_lineitem_partsuppkey=[differential join] // { arity: 16 }
  1617. Used Indexes:
  1618. - materialize.public.pk_nation_nationkey (differential join)
  1619. - materialize.public.pk_part_partkey (*** full scan ***)
  1620. - materialize.public.fk_supplier_nationkey (differential join)
  1621. - materialize.public.pk_partsupp_partkey_suppkey (*** full scan ***)
  1622. - materialize.public.fk_lineitem_partsuppkey (differential join)
  1623. Target cluster: quickstart
  1624. EOF
  1625. statement ok
  1626. -- Query 21
  1627. CREATE VIEW Q21 AS
  1628. SELECT
  1629. s_name,
  1630. count(*) AS numwait
  1631. FROM
  1632. supplier,
  1633. lineitem l1,
  1634. orders,
  1635. nation
  1636. WHERE
  1637. s_suppkey = l1.l_suppkey
  1638. AND o_orderkey = l1.l_orderkey
  1639. AND o_orderstatus = 'F'
  1640. AND l1.l_receiptdate > l1.l_commitdate
  1641. AND EXISTS (
  1642. SELECT
  1643. *
  1644. FROM
  1645. lineitem l2
  1646. WHERE
  1647. l2.l_orderkey = l1.l_orderkey
  1648. AND l2.l_suppkey <> l1.l_suppkey
  1649. )
  1650. AND not EXISTS (
  1651. SELECT
  1652. *
  1653. FROM
  1654. lineitem l3
  1655. WHERE
  1656. l3.l_orderkey = l1.l_orderkey
  1657. AND l3.l_suppkey <> l1.l_suppkey
  1658. AND l3.l_receiptdate > l3.l_commitdate
  1659. )
  1660. AND s_nationkey = n_nationkey
  1661. AND n_name = 'SAUDI ARABIA'
  1662. GROUP BY
  1663. s_name
  1664. ORDER BY
  1665. numwait DESC,
  1666. s_name;
  1667. query T multiline
  1668. -- Explain index on Q21
  1669. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1670. CREATE DEFAULT INDEX ON Q21;
  1671. ----
  1672. materialize.public.q21_primary_idx:
  1673. ArrangeBy keys=[[#0{s_name}]] // { arity: 2 }
  1674. ReadGlobalFromSameDataflow materialize.public.q21 // { arity: 2 }
  1675. materialize.public.q21:
  1676. With
  1677. cte l0 =
  1678. Project (#0{s_suppkey}, #1{s_name}, #7{l_orderkey}) // { arity: 3 }
  1679. Filter (#25{o_orderstatus} = "F") AND (#33{n_name} = "SAUDI ARABIA") AND (#19{l_receiptdate} > #18{l_commitdate}) // { arity: 36 }
  1680. Join on=(#0{s_suppkey} = #9{l_suppkey} AND #3{s_nationkey} = #32{n_nationkey} AND #7{l_orderkey} = #23{o_orderkey}) type=delta // { arity: 36 }
  1681. implementation
  1682. %0:supplier » %3:nation[#0{n_nationkey}]KAef » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef
  1683. %1:lineitem » %2:orders[#0{o_orderkey}]KAef » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef
  1684. %2:orders » %1:lineitem[#0{l_orderkey}]KAf » %0:supplier[#0{s_suppkey}]KA » %3:nation[#0{n_nationkey}]KAef
  1685. %3:nation » %0:supplier[#3{s_nationkey}]KA » %1:lineitem[#2{l_suppkey}]KAf » %2:orders[#0{o_orderkey}]KAef
  1686. ArrangeBy keys=[[#0{s_suppkey}], [#3{s_nationkey}]] // { arity: 7 }
  1687. ReadIndex on=supplier pk_supplier_suppkey=[delta join 1st input (full scan)] fk_supplier_nationkey=[delta join lookup] // { arity: 7 }
  1688. ArrangeBy keys=[[#0{l_orderkey}], [#2{l_suppkey}]] // { arity: 16 }
  1689. ReadIndex on=lineitem fk_lineitem_orderkey=[delta join lookup] fk_lineitem_suppkey=[delta join lookup] // { arity: 16 }
  1690. ArrangeBy keys=[[#0{o_orderkey}]] // { arity: 9 }
  1691. ReadIndex on=orders pk_orders_orderkey=[delta join lookup] // { arity: 9 }
  1692. ArrangeBy keys=[[#0{n_nationkey}]] // { arity: 4 }
  1693. ReadIndex on=nation pk_nation_nationkey=[delta join lookup] // { arity: 4 }
  1694. cte l1 =
  1695. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 16 }
  1696. ReadIndex on=lineitem fk_lineitem_orderkey=[differential join] // { arity: 16 }
  1697. cte l2 =
  1698. Project (#0{s_suppkey}..=#2{l_orderkey}) // { arity: 3 }
  1699. Join on=(#0{s_suppkey} = #4{s_suppkey} AND #2{l_orderkey} = #3{l_orderkey}) type=differential // { arity: 5 }
  1700. implementation
  1701. %1[#1, #0]UKK » %0:l0[#0, #2]KK
  1702. ArrangeBy keys=[[#0{s_suppkey}, #2{l_orderkey}]] // { arity: 3 }
  1703. Get l0 // { arity: 3 }
  1704. ArrangeBy keys=[[#1{s_suppkey}, #0{l_orderkey}]] // { arity: 2 }
  1705. Distinct project=[#0{l_orderkey}, #1{s_suppkey}] // { arity: 2 }
  1706. Project (#0{l_orderkey}, #1{s_suppkey}) // { arity: 2 }
  1707. Filter (#1{s_suppkey} != #4{l_suppkey}) // { arity: 18 }
  1708. Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 }
  1709. implementation
  1710. %1:l1[#0{l_orderkey}]KA » %0[#0{l_orderkey}]K
  1711. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 }
  1712. Distinct project=[#1{l_orderkey}, #0{s_suppkey}] // { arity: 2 }
  1713. Project (#0{s_suppkey}, #2{l_orderkey}) // { arity: 2 }
  1714. Get l0 // { arity: 3 }
  1715. Get l1 // { arity: 16 }
  1716. cte l3 =
  1717. Distinct project=[#1{l_orderkey}, #0{s_suppkey}] // { arity: 2 }
  1718. Project (#0{s_suppkey}, #2{l_orderkey}) // { arity: 2 }
  1719. Get l2 // { arity: 3 }
  1720. Return // { arity: 2 }
  1721. Reduce group_by=[#0{s_name}] aggregates=[count(*)] // { arity: 2 }
  1722. Project (#1{s_name}) // { arity: 1 }
  1723. Join on=(#0{s_suppkey} = #4{s_suppkey} AND #2{l_orderkey} = #3{l_orderkey}) type=differential // { arity: 5 }
  1724. implementation
  1725. %0:l2[#2, #0]KK » %1[#0, #1]KK
  1726. ArrangeBy keys=[[#2{l_orderkey}, #0{s_suppkey}]] // { arity: 3 }
  1727. Get l2 // { arity: 3 }
  1728. ArrangeBy keys=[[#0{l_orderkey}, #1{s_suppkey}]] // { arity: 2 }
  1729. Union // { arity: 2 }
  1730. Negate // { arity: 2 }
  1731. Distinct project=[#0{l_orderkey}, #1{s_suppkey}] // { arity: 2 }
  1732. Project (#0{l_orderkey}, #1{s_suppkey}) // { arity: 2 }
  1733. Filter (#1{s_suppkey} != #4{l_suppkey}) AND (#14{l_receiptdate} > #13{l_commitdate}) // { arity: 18 }
  1734. Join on=(#0{l_orderkey} = #2{l_orderkey}) type=differential // { arity: 18 }
  1735. implementation
  1736. %1:l1[#0{l_orderkey}]KAf » %0:l3[#0{l_orderkey}]Kf
  1737. ArrangeBy keys=[[#0{l_orderkey}]] // { arity: 2 }
  1738. Get l3 // { arity: 2 }
  1739. Get l1 // { arity: 16 }
  1740. Get l3 // { arity: 2 }
  1741. Used Indexes:
  1742. - materialize.public.pk_nation_nationkey (delta join lookup)
  1743. - materialize.public.pk_supplier_suppkey (delta join 1st input (full scan))
  1744. - materialize.public.fk_supplier_nationkey (delta join lookup)
  1745. - materialize.public.pk_orders_orderkey (delta join lookup)
  1746. - materialize.public.fk_lineitem_orderkey (differential join, delta join lookup)
  1747. - materialize.public.fk_lineitem_suppkey (delta join lookup)
  1748. Target cluster: quickstart
  1749. EOF
  1750. statement ok
  1751. -- Query 22
  1752. CREATE VIEW Q22 AS
  1753. SELECT
  1754. cntrycode,
  1755. count(*) AS numcust,
  1756. sum(c_acctbal) AS totacctbal
  1757. FROM
  1758. (
  1759. SELECT
  1760. substring(c_phone, 1, 2) AS cntrycode, c_acctbal
  1761. FROM
  1762. customer
  1763. WHERE
  1764. substring(c_phone, 1, 2)
  1765. IN ('13', '31', '23', '29', '30', '18', '17')
  1766. AND c_acctbal
  1767. > (
  1768. SELECT
  1769. avg(c_acctbal)
  1770. FROM
  1771. customer
  1772. WHERE
  1773. c_acctbal > 0.00
  1774. AND substring(c_phone, 1, 2)
  1775. IN (
  1776. '13',
  1777. '31',
  1778. '23',
  1779. '29',
  1780. '30',
  1781. '18',
  1782. '17'
  1783. )
  1784. )
  1785. AND NOT
  1786. EXISTS(
  1787. SELECT
  1788. *
  1789. FROM
  1790. orders
  1791. WHERE
  1792. o_custkey = c_custkey
  1793. )
  1794. )
  1795. AS custsale
  1796. GROUP BY
  1797. cntrycode
  1798. ORDER BY
  1799. cntrycode;
  1800. query T multiline
  1801. -- Explain index on Q22
  1802. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  1803. CREATE DEFAULT INDEX ON Q22;
  1804. ----
  1805. materialize.public.q22_primary_idx:
  1806. ArrangeBy keys=[[#0{cntrycode}]] // { arity: 3 }
  1807. ReadGlobalFromSameDataflow materialize.public.q22 // { arity: 3 }
  1808. materialize.public.q22:
  1809. With
  1810. cte l0 =
  1811. Project (#0{c_custkey}, #4{c_phone}, #5{c_acctbal}, #8) // { arity: 4 }
  1812. Map (substr(char_to_text(#4{c_phone}), 1, 2)) // { arity: 9 }
  1813. ReadIndex on=customer pk_customer_custkey=[*** full scan ***] // { arity: 8 }
  1814. cte l1 =
  1815. Project (#0{c_custkey}..=#2{c_acctbal}) // { arity: 3 }
  1816. Filter (#2{c_acctbal} > (#3{sum_c_acctbal} / bigint_to_numeric(case when (#4{count} = 0) then null else #4{count} end))) // { arity: 5 }
  1817. CrossJoin type=differential // { arity: 5 }
  1818. implementation
  1819. %1[×]UA » %0:l0[×]ef
  1820. ArrangeBy keys=[[]] // { arity: 3 }
  1821. Project (#0{c_custkey}..=#2{c_acctbal}) // { arity: 3 }
  1822. Filter ((#3 = "13") OR (#3 = "17") OR (#3 = "18") OR (#3 = "23") OR (#3 = "29") OR (#3 = "30") OR (#3 = "31")) // { arity: 4 }
  1823. Get l0 // { arity: 4 }
  1824. ArrangeBy keys=[[]] // { arity: 2 }
  1825. Reduce aggregates=[sum(#0{c_acctbal}), count(*)] // { arity: 2 }
  1826. Project (#2{c_acctbal}) // { arity: 1 }
  1827. Filter (#2{c_acctbal} > 0) AND ((#3 = "13") OR (#3 = "17") OR (#3 = "18") OR (#3 = "23") OR (#3 = "29") OR (#3 = "30") OR (#3 = "31")) // { arity: 4 }
  1828. Get l0 // { arity: 4 }
  1829. cte l2 =
  1830. Distinct project=[#0{c_custkey}] // { arity: 1 }
  1831. Project (#0{c_custkey}) // { arity: 1 }
  1832. Get l1 // { arity: 3 }
  1833. Return // { arity: 3 }
  1834. Reduce group_by=[substr(char_to_text(#0{c_phone}), 1, 2)] aggregates=[count(*), sum(#1{c_acctbal})] // { arity: 3 }
  1835. Project (#1{c_phone}, #2{c_acctbal}) // { arity: 2 }
  1836. Join on=(#0{c_custkey} = #3{c_custkey}) type=differential // { arity: 4 }
  1837. implementation
  1838. %0:l1[#0]K » %1[#0]K
  1839. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 3 }
  1840. Get l1 // { arity: 3 }
  1841. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 1 }
  1842. Union // { arity: 1 }
  1843. Negate // { arity: 1 }
  1844. Project (#0{c_custkey}) // { arity: 1 }
  1845. Join on=(#0{c_custkey} = #1{o_custkey}) type=differential // { arity: 2 }
  1846. implementation
  1847. %0:l2[#0]UKA » %1[#0]UKA
  1848. ArrangeBy keys=[[#0{c_custkey}]] // { arity: 1 }
  1849. Get l2 // { arity: 1 }
  1850. ArrangeBy keys=[[#0{o_custkey}]] // { arity: 1 }
  1851. Distinct project=[#0{o_custkey}] // { arity: 1 }
  1852. Project (#1{o_custkey}) // { arity: 1 }
  1853. ReadIndex on=orders pk_orders_orderkey=[*** full scan ***] // { arity: 9 }
  1854. Get l2 // { arity: 1 }
  1855. Used Indexes:
  1856. - materialize.public.pk_customer_custkey (*** full scan ***)
  1857. - materialize.public.pk_orders_orderkey (*** full scan ***)
  1858. Target cluster: quickstart
  1859. EOF