cardinality.slt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. # testing cardinality estimation
  10. simple conn=mz_system,user=mz_system
  11. ALTER SYSTEM SET enable_cardinality_estimates = true
  12. ----
  13. COMPLETE 0
  14. # avoid flakes in CI
  15. # Was flaky with 100ms. Look into this when starting to use cardinality for real!
  16. simple conn=mz_system,user=mz_system
  17. ALTER SYSTEM SET optimizer_oneshot_stats_timeout TO '500ms'
  18. ----
  19. COMPLETE 0
  20. simple
  21. SET ENABLE_SESSION_CARDINALITY_ESTIMATES TO TRUE
  22. ----
  23. COMPLETE 0
  24. statement ok
  25. CREATE TABLE t (x INTEGER NOT NULL, y INTEGER NOT NULL);
  26. statement ok
  27. CREATE TABLE t2 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  28. statement ok
  29. CREATE INDEX t_x ON t (x);
  30. statement ok
  31. CREATE INDEX tt_x ON t2 (x);
  32. statement ok
  33. CREATE TABLE cities (name TEXT NOT NULL, state TEXT NOT NULL, pop integer);
  34. statement ok
  35. CREATE TABLE states (state TEXT NOT NULL, pop integer);
  36. statement ok
  37. CREATE INDEX cities_name ON cities (name);
  38. statement ok
  39. CREATE INDEX cities_state ON cities (state);
  40. statement ok
  41. CREATE INDEX cities_name_and_state ON cities (name, state);
  42. statement ok
  43. CREATE INDEX state_state ON states (state);
  44. statement ok
  45. INSERT INTO t (x, y) VALUES (1, 1), (1, 2), (2, 3), (3, 1)
  46. query T multiline
  47. EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM t as l, t as r WHERE l.x = r.x;
  48. ----
  49. Explained Query:
  50. With
  51. cte l0 =
  52. ArrangeBy keys=[[#0{x}]]
  53. ReadIndex on=t t_x=[differential join]
  54. Return
  55. Project (#0{x}, #1{y}, #0{x}, #3{y})
  56. Join on=(#0{x} = #2{x}) type=differential
  57. implementation
  58. %0:l0[#0{x}]KA|4| » %1:l0[#0{x}]KA|4|
  59. Get l0
  60. Get l0
  61. Used Indexes:
  62. - materialize.public.t_x (differential join)
  63. Target cluster: quickstart
  64. EOF
  65. statement ok
  66. INSERT INTO t2 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 200)) AS l, (SELECT generate_series(1, 50)) AS r
  67. query T multiline
  68. EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM t, t2 WHERE t.x = t2.x;
  69. ----
  70. Explained Query:
  71. Project (#0{x}, #1{y}, #0{x}, #3{y})
  72. Join on=(#0{x} = #2{x}) type=differential
  73. implementation
  74. %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000|
  75. ArrangeBy keys=[[#0{x}]]
  76. ReadIndex on=t t_x=[differential join]
  77. ArrangeBy keys=[[#0{x}]]
  78. ReadIndex on=t2 tt_x=[differential join]
  79. Used Indexes:
  80. - materialize.public.t_x (differential join)
  81. - materialize.public.tt_x (differential join)
  82. Target cluster: quickstart
  83. EOF
  84. # regression test drawn from LDBC-BI query 15 for having a selectivity of 0
  85. # TODO(mgree): we could probably trim this down to be tighter, but the optimizer has been too clever for me
  86. statement ok
  87. CREATE TABLE Person_knows_Person (
  88. creationDate timestamp with time zone NOT NULL,
  89. Person1id bigint NOT NULL,
  90. Person2id bigint NOT NULL
  91. )
  92. statement ok
  93. CREATE INDEX Person_knows_Person_Person1id_Person2id ON Person_knows_Person (Person1id, Person2id)
  94. query T multiline
  95. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR WITH MUTUALLY RECURSIVE
  96. mm (src bigint, dst bigint, w bigint) AS (SELECT 3::bigint, 4::bigint, 5::bigint),
  97. path (src bigint, dst bigint, w double precision) AS (
  98. SELECT pp.person1id, pp.person2id, 10::double precision / (coalesce(w, 0) + 10)
  99. FROM Person_knows_Person pp left join mm on least(pp.person1id, pp.person2id) = mm.src AND greatest(pp.person1id, pp.person2id) = mm.dst
  100. ),
  101. pexists (src bigint, dir bool) AS (
  102. (
  103. SELECT 1::bigint, true
  104. UNION
  105. SELECT 2::bigint, false
  106. )
  107. UNION
  108. (
  109. WITH
  110. ss (src, dir) AS (SELECT src, dir FROM pexists),
  111. ns (src, dir) AS (SELECT p.dst, ss.dir FROM ss, path p WHERE ss.src = p.src),
  112. bb (src, dir) AS (SELECT src, dir FROM ns UNION ALL SELECT src, dir FROM ss),
  113. found (found) AS (
  114. SELECT 1 AS found
  115. FROM bb b1, bb b2
  116. WHERE b1.dir AND (NOT b2.dir) AND b1.src = b2.src
  117. )
  118. SELECT src, dir
  119. FROM ns
  120. WHERE NOT EXISTS (SELECT 1 FROM found)
  121. UNION
  122. SELECT -1, true
  123. WHERE EXISTS (SELECT 1 FROM found)
  124. )
  125. ),
  126. pathfound (c bool) AS (
  127. SELECT true AS c
  128. FROM pexists
  129. WHERE src = -1 AND dir
  130. )
  131. SELECT * FROM pexists;
  132. ----
  133. Explained Query:
  134. With Mutually Recursive
  135. cte l0 =
  136. Project (#1, #3{person2id})
  137. Join on=(#0{src} = #2{person1id}) type=differential
  138. ArrangeBy keys=[[#0{person2id}]]
  139. Get l3
  140. ArrangeBy keys=[[#0{person1id}]]
  141. Project (#1{person1id}, #2{person2id})
  142. ReadIndex on=person_knows_person person_knows_person_person1id_person2id=[*** full scan ***]
  143. cte l1 =
  144. Union
  145. Project (#1{person2id}, #0)
  146. Get l0
  147. Get l3
  148. cte l2 =
  149. Distinct project=[]
  150. Project ()
  151. Join on=(#0{person2id} = #1{person2id}) type=differential
  152. ArrangeBy keys=[[#0{person2id}]]
  153. Project (#0{person2id})
  154. Filter #1{dir}
  155. Get l1
  156. ArrangeBy keys=[[#0{person2id}]]
  157. Project (#0{person2id})
  158. Filter NOT(#1{dir})
  159. Get l1
  160. cte l3 =
  161. Distinct project=[#0{person2id}, #1]
  162. Union
  163. Project (#1{person2id}, #0)
  164. CrossJoin type=differential
  165. ArrangeBy keys=[[]]
  166. Get l0
  167. ArrangeBy keys=[[]]
  168. Union
  169. Negate
  170. Get l2
  171. Constant
  172. - ()
  173. Project (#1, #0)
  174. Map (true, -1)
  175. Get l2
  176. Constant
  177. - (1, true)
  178. - (2, false)
  179. Return
  180. Get l3
  181. Used Indexes:
  182. - materialize.public.person_knows_person_person1id_person2id (*** full scan ***)
  183. Target cluster: quickstart
  184. EOF
  185. # regression test drawn from LDBC-BI query 15 for having a selectivity of 0
  186. # TODO(mgree): we could probably trim this down to be tighter, but the optimizer has been too clever for me
  187. query T multiline
  188. EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR WITH MUTUALLY RECURSIVE
  189. mm (src bigint, dst bigint, w bigint) AS (SELECT 3::bigint, 4::bigint, 5::bigint),
  190. path (src bigint, dst bigint, w double precision) AS (
  191. SELECT pp.person1id, pp.person2id, 10::double precision / (coalesce(w, 0) + 10)
  192. FROM Person_knows_Person pp left join mm on least(pp.person1id, pp.person2id) = mm.src AND greatest(pp.person1id, pp.person2id) = mm.dst
  193. ),
  194. pexists (src bigint, dir bool) AS (
  195. (
  196. SELECT 1::bigint, true
  197. UNION
  198. SELECT 2::bigint, false
  199. )
  200. UNION
  201. (
  202. WITH
  203. ss (src, dir) AS (SELECT src, dir FROM pexists),
  204. ns (src, dir) AS (SELECT p.dst, ss.dir FROM ss, path p WHERE ss.src = p.src),
  205. bb (src, dir) AS (SELECT src, dir FROM ns UNION ALL SELECT src, dir FROM ss),
  206. found (found) AS (
  207. SELECT 1 AS found
  208. FROM bb b1, bb b2
  209. WHERE b1.dir AND (NOT b2.dir) AND b1.src = b2.src
  210. )
  211. SELECT src, dir
  212. FROM ns
  213. WHERE NOT EXISTS (SELECT 1 FROM found)
  214. UNION
  215. SELECT -1, true
  216. WHERE EXISTS (SELECT 1 FROM found)
  217. )
  218. ),
  219. pathfound (c bool) AS (
  220. SELECT true AS c
  221. FROM pexists
  222. WHERE src = -1 AND dir
  223. )
  224. SELECT * FROM pexists;
  225. ----
  226. Explained Query:
  227. With Mutually Recursive
  228. cte l0 =
  229. Project (#1, #3{person2id})
  230. Join on=(#0{src} = #2{person1id}) type=differential
  231. ArrangeBy keys=[[#0{person2id}]]
  232. Get l3
  233. ArrangeBy keys=[[#0{person1id}]]
  234. Project (#1{person1id}, #2{person2id})
  235. ReadIndex on=person_knows_person person_knows_person_person1id_person2id=[*** full scan ***]
  236. cte l1 =
  237. Union
  238. Project (#1{person2id}, #0)
  239. Get l0
  240. Get l3
  241. cte l2 =
  242. Distinct project=[]
  243. Project ()
  244. Join on=(#0{person2id} = #1{person2id}) type=differential
  245. ArrangeBy keys=[[#0{person2id}]]
  246. Project (#0{person2id})
  247. Filter #1{dir}
  248. Get l1
  249. ArrangeBy keys=[[#0{person2id}]]
  250. Project (#0{person2id})
  251. Filter NOT(#1{dir})
  252. Get l1
  253. cte l3 =
  254. Distinct project=[#0{person2id}, #1]
  255. Union
  256. Project (#1{person2id}, #0)
  257. CrossJoin type=differential
  258. ArrangeBy keys=[[]]
  259. Get l0
  260. ArrangeBy keys=[[]]
  261. Union
  262. Negate
  263. Get l2
  264. Constant
  265. - ()
  266. Project (#1, #0)
  267. Map (true, -1)
  268. Get l2
  269. Constant
  270. - (1, true)
  271. - (2, false)
  272. Return
  273. Get l3
  274. Used Indexes:
  275. - materialize.public.person_knows_person_person1id_person2id (*** full scan ***)
  276. Target cluster: quickstart
  277. EOF
  278. # timeouts should work
  279. simple conn=mz_system,user=mz_system
  280. ALTER SYSTEM SET optimizer_oneshot_stats_timeout TO '1us';
  281. ----
  282. COMPLETE 0
  283. simple conn=mz_system,user=mz_system
  284. SHOW optimizer_oneshot_stats_timeout;
  285. ----
  286. 1 us
  287. COMPLETE 1
  288. statement ok
  289. CREATE TABLE t3 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  290. statement ok
  291. CREATE TABLE t4 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  292. statement ok
  293. CREATE TABLE t5 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  294. statement ok
  295. CREATE TABLE t6 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  296. statement ok
  297. CREATE TABLE t7 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  298. statement ok
  299. CREATE TABLE t8 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  300. statement ok
  301. CREATE TABLE t9 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  302. statement ok
  303. CREATE TABLE t10 (x INTEGER NOT NULL, y INTEGER NOT NULL);
  304. statement ok
  305. INSERT INTO t3 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 13)) AS l, (SELECT generate_series(1, 13)) AS r
  306. statement ok
  307. INSERT INTO t4 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 47)) AS l, (SELECT generate_series(1, 13)) AS r
  308. statement ok
  309. INSERT INTO t5 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 38)) AS l, (SELECT generate_series(1, 13)) AS r
  310. statement ok
  311. INSERT INTO t6 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 23)) AS l, (SELECT generate_series(1, 13)) AS r
  312. statement ok
  313. INSERT INTO t7 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 23)) AS l, (SELECT generate_series(1, 13)) AS r
  314. statement ok
  315. INSERT INTO t8 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 23)) AS l, (SELECT generate_series(1, 13)) AS r
  316. statement ok
  317. INSERT INTO t9 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 21)) AS l, (SELECT generate_series(1, 13)) AS r
  318. statement ok
  319. INSERT INTO t10 (x, y) SELECT l.*, r.* FROM (SELECT generate_series(1, 20)) AS l, (SELECT generate_series(1, 13)) AS r
  320. # TODO(mgree): Make this reproducible
  321. # query T multiline
  322. # EXPLAIN WITH(join implementations) SELECT * FROM t JOIN t2 ON t.x = t2.x JOIN t3 ON t.x = t3.x JOIN t4 ON t.x = t4.x JOIN t5 ON t.x = t5.x JOIN t6 ON t.x = t6.x JOIN t7 ON t.x = t7.x JOIN t8 ON t.x = t8.x JOIN t9 ON t.x = t9.x JOIN t10 ON t.x = t10.x;
  323. # ----
  324. # Explained Query:
  325. # Project (#0, #1, #0, #3, #0, #5, #0, #7, #0, #9, #0, #11, #0, #13, #0, #15, #0, #17, #0, #19)
  326. # Join on=(eq(#0, #2, #4, #6, #8, #10, #12, #14, #16, #18)) type=delta
  327. # implementation
  328. # %0:t » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  329. # %1:t2 » %0:t[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  330. # %2:t3 » %0:t[#0]KA » %1:t2[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  331. # %3:t4 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  332. # %4:t5 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  333. # %5:t6 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  334. # %6:t7 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  335. # %7:t8 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %8:t9[#0]KA » %9:t10[#0]KA
  336. # %8:t9 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %9:t10[#0]KA
  337. # %9:t10 » %0:t[#0]KA » %1:t2[#0]KA » %2:t3[#0]KA » %3:t4[#0]KA » %4:t5[#0]KA » %5:t6[#0]KA » %6:t7[#0]KA » %7:t8[#0]KA » %8:t9[#0]KA
  338. # ArrangeBy keys=[[#0]]
  339. # ReadIndex on=t t_x=[delta join 1st input (full scan)]
  340. # ArrangeBy keys=[[#0]]
  341. # ReadIndex on=t2 tt_x=[delta join lookup]
  342. # ArrangeBy keys=[[#0]]
  343. # ReadStorage materialize.public.t3
  344. # ArrangeBy keys=[[#0]]
  345. # ReadStorage materialize.public.t4
  346. # ArrangeBy keys=[[#0]]
  347. # ReadStorage materialize.public.t5
  348. # ArrangeBy keys=[[#0]]
  349. # ReadStorage materialize.public.t6
  350. # ArrangeBy keys=[[#0]]
  351. # ReadStorage materialize.public.t7
  352. # ArrangeBy keys=[[#0]]
  353. # ReadStorage materialize.public.t8
  354. # ArrangeBy keys=[[#0]]
  355. # ReadStorage materialize.public.t9
  356. # ArrangeBy keys=[[#0]]
  357. # ReadStorage materialize.public.t10
  358. #
  359. # Used Indexes:
  360. # - materialize.public.t_x (delta join 1st input (full scan))
  361. # - materialize.public.tt_x (delta join lookup)
  362. #
  363. # EOF
  364. # restore and make sure we're good
  365. simple conn=mz_system,user=mz_system
  366. ALTER SYSTEM SET optimizer_oneshot_stats_timeout TO '20ms';
  367. ----
  368. COMPLETE 0
  369. simple conn=mz_system,user=mz_system
  370. SHOW optimizer_oneshot_stats_timeout;
  371. ----
  372. 20 ms
  373. COMPLETE 1
  374. statement ok
  375. SELECT mz_unsafe.mz_sleep(5)
  376. query T multiline
  377. EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM t JOIN t2 ON t.x = t2.x JOIN t3 ON t.x = t3.x JOIN t4 ON t.x = t4.x JOIN t5 ON t.x = t5.x JOIN t6 ON t.x = t6.x JOIN t7 ON t.x = t7.x JOIN t8 ON t.x = t8.x JOIN t9 ON t.x = t9.x JOIN t10 ON t.x = t10.x;
  378. ----
  379. Explained Query:
  380. Project (#0{x}, #1{y}, #0{x}, #3{y}, #0{x}, #5{y}, #0{x}, #7{y}, #0{x}, #9{y}, #0{x}, #11{y}, #0{x}, #13{y}, #0{x}, #15{y}, #0{x}, #17{y}, #0{x}, #19{y})
  381. Join on=(#0{x} = #2{x} = #4{x} = #6{x} = #8{x} = #10{x} = #12{x} = #14{x} = #16{x} = #18{x}) type=delta
  382. implementation
  383. %0:t » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  384. %1:t2 » %0:t[#0{x}]KA|4| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  385. %2:t3 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  386. %3:t4 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494|
  387. %4:t5 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %3:t4[#0{x}]K|611|
  388. %5:t6 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  389. %6:t7 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  390. %7:t8 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  391. %8:t9 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %9:t10[#0{x}]K|260| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  392. %9:t10 » %0:t[#0{x}]KA|4| » %1:t2[#0{x}]KA|10000| » %2:t3[#0{x}]K|169| » %8:t9[#0{x}]K|273| » %5:t6[#0{x}]K|299| » %6:t7[#0{x}]K|299| » %7:t8[#0{x}]K|299| » %4:t5[#0{x}]K|494| » %3:t4[#0{x}]K|611|
  393. ArrangeBy keys=[[#0{x}]]
  394. ReadIndex on=t t_x=[delta join 1st input (full scan)]
  395. ArrangeBy keys=[[#0{x}]]
  396. ReadIndex on=t2 tt_x=[delta join lookup]
  397. ArrangeBy keys=[[#0{x}]]
  398. ReadStorage materialize.public.t3
  399. ArrangeBy keys=[[#0{x}]]
  400. ReadStorage materialize.public.t4
  401. ArrangeBy keys=[[#0{x}]]
  402. ReadStorage materialize.public.t5
  403. ArrangeBy keys=[[#0{x}]]
  404. ReadStorage materialize.public.t6
  405. ArrangeBy keys=[[#0{x}]]
  406. ReadStorage materialize.public.t7
  407. ArrangeBy keys=[[#0{x}]]
  408. ReadStorage materialize.public.t8
  409. ArrangeBy keys=[[#0{x}]]
  410. ReadStorage materialize.public.t9
  411. ArrangeBy keys=[[#0{x}]]
  412. ReadStorage materialize.public.t10
  413. Source materialize.public.t3
  414. Source materialize.public.t4
  415. Source materialize.public.t5
  416. Source materialize.public.t6
  417. Source materialize.public.t7
  418. Source materialize.public.t8
  419. Source materialize.public.t9
  420. Source materialize.public.t10
  421. Used Indexes:
  422. - materialize.public.t_x (delta join 1st input (full scan))
  423. - materialize.public.tt_x (delta join lookup)
  424. Target cluster: quickstart
  425. EOF
  426. # Regression test for gh issue 27348 (cardinality + WMR panic)
  427. query T multiline
  428. EXPLAIN OPTIMIZED PLAN WITH(cardinality, humanized expressions) AS VERBOSE TEXT FOR
  429. WITH MUTUALLY RECURSIVE
  430. t(x int) AS (SELECT 1 UNION ALL SELECT * FROM u),
  431. u(x int) AS (SELECT t.x+1 FROM t WHERE x < 7)
  432. SELECT * FROM t;
  433. ----
  434. Explained Query:
  435. With Mutually Recursive
  436. cte l0 =
  437. Union // { cardinality: "<UNKNOWN>" }
  438. Get l1 // { cardinality: "<UNKNOWN>" }
  439. Constant // { cardinality: "1" }
  440. - (1)
  441. cte l1 =
  442. Project (#1) // { cardinality: "<UNKNOWN>" }
  443. Filter (#0{x} < 7) // { cardinality: "<UNKNOWN>" }
  444. Map ((#0{x} + 1)) // { cardinality: "<UNKNOWN>" }
  445. Get l0 // { cardinality: "<UNKNOWN>" }
  446. Return // { cardinality: "<UNKNOWN>" }
  447. Get l0 // { cardinality: "<UNKNOWN>" }
  448. Target cluster: mz_catalog_server
  449. EOF