scalability.slt 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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. # Queries that particulary stress the optimizer.
  10. # The passing criteria of the tests in this file is:
  11. # 1. they should not result in crashes
  12. # 2. they should not lead to planning issues, mostly fixpoint issues
  13. statement ok
  14. create table events(origin_id int, category_id int, payload jsonb, timestamp_col timestamp);
  15. statement ok
  16. create table origins(id int, category_id int);
  17. # Regression test for database-issues#2558
  18. # Ignoring the plan on purpose. We just want to check we can handle the query.
  19. statement ok
  20. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  21. SELECT
  22. (SELECT max(timestamp_col)
  23. FROM events
  24. WHERE (payload->>'type' = 'foo1'
  25. AND category_id = origins.category_id
  26. AND origin_id = origins.id
  27. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  28. )
  29. ) AS quz__foo1_types__max_time__90days,
  30. (SELECT max(timestamp_col)
  31. FROM events
  32. WHERE (payload->>'type' = 'foo1'
  33. AND category_id = origins.category_id
  34. AND origin_id = origins.id
  35. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  36. )
  37. ) AS quz__foo1_types__max_time__90days,
  38. (SELECT max(timestamp_col)
  39. FROM events
  40. WHERE (payload->>'type' = 'foo1'
  41. AND category_id = origins.category_id
  42. AND origin_id = origins.id
  43. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  44. )
  45. ) AS quz__foo1_types__max_time__90days,
  46. (SELECT max(timestamp_col)
  47. FROM events
  48. WHERE (payload->>'type' = 'foo1'
  49. AND category_id = origins.category_id
  50. AND origin_id = origins.id
  51. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  52. )
  53. ) AS quz__foo1_types__max_time__90days,
  54. (SELECT max(timestamp_col)
  55. FROM events
  56. WHERE (payload->>'type' = 'foo1'
  57. AND category_id = origins.category_id
  58. AND origin_id = origins.id
  59. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  60. )
  61. ) AS quz__foo1_types__max_time__90days,
  62. (SELECT max(timestamp_col)
  63. FROM events
  64. WHERE (payload->>'type' = 'foo1'
  65. AND category_id = origins.category_id
  66. AND origin_id = origins.id
  67. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  68. )
  69. ) AS quz__foo1_types__max_time__90days,
  70. (SELECT max(timestamp_col)
  71. FROM events
  72. WHERE (payload->>'type' = 'foo1'
  73. AND category_id = origins.category_id
  74. AND origin_id = origins.id
  75. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  76. )
  77. ) AS quz__foo1_types__max_time__90days,
  78. (SELECT max(timestamp_col)
  79. FROM events
  80. WHERE (payload->>'type' = 'foo1'
  81. AND category_id = origins.category_id
  82. AND origin_id = origins.id
  83. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  84. )
  85. ) AS quz__foo1_types__max_time__90days,
  86. (SELECT max(timestamp_col)
  87. FROM events
  88. WHERE (payload->>'type' = 'foo1'
  89. AND category_id = origins.category_id
  90. AND origin_id = origins.id
  91. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  92. )
  93. ) AS quz__foo1_types__max_time__90days,
  94. (SELECT max(timestamp_col)
  95. FROM events
  96. WHERE (payload->>'type' = 'foo1'
  97. AND category_id = origins.category_id
  98. AND origin_id = origins.id
  99. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  100. )
  101. ) AS quz__foo1_types__max_time__90days,
  102. (SELECT max(timestamp_col)
  103. FROM events
  104. WHERE (payload->>'type' = 'foo1'
  105. AND category_id = origins.category_id
  106. AND origin_id = origins.id
  107. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  108. )
  109. ) AS quz__foo1_types__max_time__90days,
  110. (SELECT max(timestamp_col)
  111. FROM events
  112. WHERE (payload->>'type' = 'foo1'
  113. AND category_id = origins.category_id
  114. AND origin_id = origins.id
  115. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  116. )
  117. ) AS quz__foo1_types__max_time__90days,
  118. (SELECT max(timestamp_col)
  119. FROM events
  120. WHERE (payload->>'type' = 'foo1'
  121. AND category_id = origins.category_id
  122. AND origin_id = origins.id
  123. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  124. )
  125. ) AS quz__foo1_types__max_time__90days,
  126. (SELECT max(timestamp_col)
  127. FROM events
  128. WHERE (payload->>'type' = 'foo1'
  129. AND category_id = origins.category_id
  130. AND origin_id = origins.id
  131. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  132. )
  133. ) AS quz__foo1_types__max_time__90days,
  134. (SELECT max(timestamp_col)
  135. FROM events
  136. WHERE (payload->>'type' = 'foo1'
  137. AND category_id = origins.category_id
  138. AND origin_id = origins.id
  139. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  140. )
  141. ) AS quz__foo1_types__max_time__90days,
  142. (SELECT max(timestamp_col)
  143. FROM events
  144. WHERE (payload->>'type' = 'foo1'
  145. AND category_id = origins.category_id
  146. AND origin_id = origins.id
  147. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  148. )
  149. ) AS quz__foo1_types__max_time__90days,
  150. (SELECT max(timestamp_col)
  151. FROM events
  152. WHERE (payload->>'type' = 'foo1'
  153. AND category_id = origins.category_id
  154. AND origin_id = origins.id
  155. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  156. )
  157. ) AS quz__foo1_types__max_time__90days,
  158. (SELECT max(timestamp_col)
  159. FROM events
  160. WHERE (payload->>'type' = 'foo1'
  161. AND category_id = origins.category_id
  162. AND origin_id = origins.id
  163. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  164. )
  165. ) AS quz__foo1_types__max_time__90days,
  166. (SELECT max(timestamp_col)
  167. FROM events
  168. WHERE (payload->>'type' = 'foo1'
  169. AND category_id = origins.category_id
  170. AND origin_id = origins.id
  171. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  172. )
  173. ) AS quz__foo1_types__max_time__90days,
  174. (SELECT max(timestamp_col)
  175. FROM events
  176. WHERE (payload->>'type' = 'foo1'
  177. AND category_id = origins.category_id
  178. AND origin_id = origins.id
  179. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  180. )
  181. ) AS quz__foo1_types__max_time__90days,
  182. (SELECT max(timestamp_col)
  183. FROM events
  184. WHERE (payload->>'type' = 'foo1'
  185. AND category_id = origins.category_id
  186. AND origin_id = origins.id
  187. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  188. )
  189. ) AS quz__foo1_types__max_time__90days,
  190. (SELECT max(timestamp_col)
  191. FROM events
  192. WHERE (payload->>'type' = 'foo1'
  193. AND category_id = origins.category_id
  194. AND origin_id = origins.id
  195. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  196. )
  197. ) AS quz__foo1_types__max_time__90days,
  198. (SELECT max(timestamp_col)
  199. FROM events
  200. WHERE (payload->>'type' = 'foo1'
  201. AND category_id = origins.category_id
  202. AND origin_id = origins.id
  203. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  204. )
  205. ) AS quz__foo1_types__max_time__90days,
  206. (SELECT max(timestamp_col)
  207. FROM events
  208. WHERE (payload->>'type' = 'foo1'
  209. AND category_id = origins.category_id
  210. AND origin_id = origins.id
  211. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  212. )
  213. ) AS quz__foo1_types__max_time__90days,
  214. (SELECT max(timestamp_col)
  215. FROM events
  216. WHERE (payload->>'type' = 'foo1'
  217. AND category_id = origins.category_id
  218. AND origin_id = origins.id
  219. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  220. )
  221. ) AS quz__foo1_types__max_time__90days,
  222. (SELECT max(timestamp_col)
  223. FROM events
  224. WHERE (payload->>'type' = 'foo1'
  225. AND category_id = origins.category_id
  226. AND origin_id = origins.id
  227. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  228. )
  229. ) AS quz__foo1_types__max_time__90days,
  230. (SELECT max(timestamp_col)
  231. FROM events
  232. WHERE (payload->>'type' = 'foo1'
  233. AND category_id = origins.category_id
  234. AND origin_id = origins.id
  235. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  236. )
  237. ) AS quz__foo1_types__max_time__90days,
  238. (SELECT max(timestamp_col)
  239. FROM events
  240. WHERE (payload->>'type' = 'foo1'
  241. AND category_id = origins.category_id
  242. AND origin_id = origins.id
  243. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  244. )
  245. ) AS quz__foo1_types__max_time__90days,
  246. (SELECT max(timestamp_col)
  247. FROM events
  248. WHERE (payload->>'type' = 'foo1'
  249. AND category_id = origins.category_id
  250. AND origin_id = origins.id
  251. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  252. )
  253. ) AS quz__foo1_types__max_time__90days,
  254. (SELECT max(timestamp_col)
  255. FROM events
  256. WHERE (payload->>'type' = 'foo1'
  257. AND category_id = origins.category_id
  258. AND origin_id = origins.id
  259. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  260. )
  261. ) AS quz__foo1_types__max_time__90days,
  262. (SELECT max(timestamp_col)
  263. FROM events
  264. WHERE (payload->>'type' = 'foo1'
  265. AND category_id = origins.category_id
  266. AND origin_id = origins.id
  267. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  268. )
  269. ) AS quz__foo1_types__max_time__90days,
  270. (SELECT max(timestamp_col)
  271. FROM events
  272. WHERE (payload->>'type' = 'foo1'
  273. AND category_id = origins.category_id
  274. AND origin_id = origins.id
  275. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  276. )
  277. ) AS quz__foo1_types__max_time__90days,
  278. (SELECT max(timestamp_col)
  279. FROM events
  280. WHERE (payload->>'type' = 'foo1'
  281. AND category_id = origins.category_id
  282. AND origin_id = origins.id
  283. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  284. )
  285. ) AS quz__foo1_types__max_time__90days,
  286. (SELECT max(timestamp_col)
  287. FROM events
  288. WHERE (payload->>'type' = 'foo1'
  289. AND category_id = origins.category_id
  290. AND origin_id = origins.id
  291. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  292. )
  293. ) AS quz__foo1_types__max_time__90days,
  294. (SELECT max(timestamp_col)
  295. FROM events
  296. WHERE (payload->>'type' = 'foo1'
  297. AND category_id = origins.category_id
  298. AND origin_id = origins.id
  299. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  300. )
  301. ) AS quz__foo1_types__max_time__90days,
  302. (SELECT max(timestamp_col)
  303. FROM events
  304. WHERE (payload->>'type' = 'foo1'
  305. AND category_id = origins.category_id
  306. AND origin_id = origins.id
  307. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  308. )
  309. ) AS quz__foo1_types__max_time__90days,
  310. (SELECT max(timestamp_col)
  311. FROM events
  312. WHERE (payload->>'type' = 'foo1'
  313. AND category_id = origins.category_id
  314. AND origin_id = origins.id
  315. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  316. )
  317. ) AS quz__foo1_types__max_time__90days,
  318. (SELECT max(timestamp_col)
  319. FROM events
  320. WHERE (payload->>'type' = 'foo1'
  321. AND category_id = origins.category_id
  322. AND origin_id = origins.id
  323. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  324. )
  325. ) AS quz__foo1_types__max_time__90days,
  326. (SELECT max(timestamp_col)
  327. FROM events
  328. WHERE (payload->>'type' = 'foo1'
  329. AND category_id = origins.category_id
  330. AND origin_id = origins.id
  331. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  332. )
  333. ) AS quz__foo1_types__max_time__90days,
  334. (SELECT max(timestamp_col)
  335. FROM events
  336. WHERE (payload->>'type' = 'foo1'
  337. AND category_id = origins.category_id
  338. AND origin_id = origins.id
  339. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  340. )
  341. ) AS quz__foo1_types__max_time__90days,
  342. (SELECT max(timestamp_col)
  343. FROM events
  344. WHERE (payload->>'type' = 'foo1'
  345. AND category_id = origins.category_id
  346. AND origin_id = origins.id
  347. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  348. )
  349. ) AS quz__foo1_types__max_time__90days,
  350. (SELECT max(timestamp_col)
  351. FROM events
  352. WHERE (payload->>'type' = 'foo1'
  353. AND category_id = origins.category_id
  354. AND origin_id = origins.id
  355. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  356. )
  357. ) AS quz__foo1_types__max_time__90days,
  358. (SELECT max(timestamp_col)
  359. FROM events
  360. WHERE (payload->>'type' = 'foo1'
  361. AND category_id = origins.category_id
  362. AND origin_id = origins.id
  363. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  364. )
  365. ) AS quz__foo1_types__max_time__90days,
  366. (SELECT max(timestamp_col)
  367. FROM events
  368. WHERE (payload->>'type' = 'foo1'
  369. AND category_id = origins.category_id
  370. AND origin_id = origins.id
  371. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  372. )
  373. ) AS quz__foo1_types__max_time__90days,
  374. (SELECT max(timestamp_col)
  375. FROM events
  376. WHERE (payload->>'type' = 'foo1'
  377. AND category_id = origins.category_id
  378. AND origin_id = origins.id
  379. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  380. )
  381. ) AS quz__foo1_types__max_time__90days,
  382. (SELECT max(timestamp_col)
  383. FROM events
  384. WHERE (payload->>'type' = 'foo1'
  385. AND category_id = origins.category_id
  386. AND origin_id = origins.id
  387. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  388. )
  389. ) AS quz__foo1_types__max_time__90days,
  390. (SELECT max(timestamp_col)
  391. FROM events
  392. WHERE (payload->>'type' = 'foo1'
  393. AND category_id = origins.category_id
  394. AND origin_id = origins.id
  395. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  396. )
  397. ) AS quz__foo1_types__max_time__90days,
  398. (SELECT max(timestamp_col)
  399. FROM events
  400. WHERE (payload->>'type' = 'foo1'
  401. AND category_id = origins.category_id
  402. AND origin_id = origins.id
  403. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  404. )
  405. ) AS quz__foo1_types__max_time__90days,
  406. (SELECT max(timestamp_col)
  407. FROM events
  408. WHERE (payload->>'type' = 'foo1'
  409. AND category_id = origins.category_id
  410. AND origin_id = origins.id
  411. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  412. )
  413. ) AS quz__foo1_types__max_time__90days,
  414. (SELECT max(timestamp_col)
  415. FROM events
  416. WHERE (payload->>'type' = 'foo1'
  417. AND category_id = origins.category_id
  418. AND origin_id = origins.id
  419. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  420. )
  421. ) AS quz__foo1_types__max_time__90days,
  422. (SELECT max(timestamp_col)
  423. FROM events
  424. WHERE (payload->>'type' = 'foo1'
  425. AND category_id = origins.category_id
  426. AND origin_id = origins.id
  427. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  428. )
  429. ) AS quz__foo1_types__max_time__90days,
  430. (SELECT max(timestamp_col)
  431. FROM events
  432. WHERE (payload->>'type' = 'foo1'
  433. AND category_id = origins.category_id
  434. AND origin_id = origins.id
  435. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  436. )
  437. ) AS quz__foo1_types__max_time__90days,
  438. (SELECT max(timestamp_col)
  439. FROM events
  440. WHERE (payload->>'type' = 'foo1'
  441. AND category_id = origins.category_id
  442. AND origin_id = origins.id
  443. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  444. )
  445. ) AS quz__foo1_types__max_time__90days,
  446. (SELECT max(timestamp_col)
  447. FROM events
  448. WHERE (payload->>'type' = 'foo1'
  449. AND category_id = origins.category_id
  450. AND origin_id = origins.id
  451. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  452. )
  453. ) AS quz__foo1_types__max_time__90days,
  454. (SELECT max(timestamp_col)
  455. FROM events
  456. WHERE (payload->>'type' = 'foo1'
  457. AND category_id = origins.category_id
  458. AND origin_id = origins.id
  459. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  460. )
  461. ) AS quz__foo1_types__max_time__90days,
  462. (SELECT max(timestamp_col)
  463. FROM events
  464. WHERE (payload->>'type' = 'foo1'
  465. AND category_id = origins.category_id
  466. AND origin_id = origins.id
  467. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  468. )
  469. ) AS quz__foo1_types__max_time__90days,
  470. (SELECT max(timestamp_col)
  471. FROM events
  472. WHERE (payload->>'type' = 'foo1'
  473. AND category_id = origins.category_id
  474. AND origin_id = origins.id
  475. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  476. )
  477. ) AS quz__foo1_types__max_time__90days,
  478. (SELECT max(timestamp_col)
  479. FROM events
  480. WHERE (payload->>'type' = 'foo1'
  481. AND category_id = origins.category_id
  482. AND origin_id = origins.id
  483. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  484. )
  485. ) AS quz__foo1_types__max_time__90days,
  486. (SELECT max(timestamp_col)
  487. FROM events
  488. WHERE (payload->>'type' = 'foo1'
  489. AND category_id = origins.category_id
  490. AND origin_id = origins.id
  491. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  492. )
  493. ) AS quz__foo1_types__max_time__90days,
  494. (SELECT max(timestamp_col)
  495. FROM events
  496. WHERE (payload->>'type' = 'foo1'
  497. AND category_id = origins.category_id
  498. AND origin_id = origins.id
  499. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  500. )
  501. ) AS quz__foo1_types__max_time__90days,
  502. (SELECT max(timestamp_col)
  503. FROM events
  504. WHERE (payload->>'type' = 'foo1'
  505. AND category_id = origins.category_id
  506. AND origin_id = origins.id
  507. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  508. )
  509. ) AS quz__foo1_types__max_time__90days,
  510. (SELECT max(timestamp_col)
  511. FROM events
  512. WHERE (payload->>'type' = 'foo1'
  513. AND category_id = origins.category_id
  514. AND origin_id = origins.id
  515. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  516. )
  517. ) AS quz__foo1_types__max_time__90days,
  518. (SELECT max(timestamp_col)
  519. FROM events
  520. WHERE (payload->>'type' = 'foo1'
  521. AND category_id = origins.category_id
  522. AND origin_id = origins.id
  523. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  524. )
  525. ) AS quz__foo1_types__max_time__90days,
  526. (SELECT max(timestamp_col)
  527. FROM events
  528. WHERE (payload->>'type' = 'foo1'
  529. AND category_id = origins.category_id
  530. AND origin_id = origins.id
  531. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  532. )
  533. ) AS quz__foo1_types__max_time__90days,
  534. (SELECT max(timestamp_col)
  535. FROM events
  536. WHERE (payload->>'type' = 'foo1'
  537. AND category_id = origins.category_id
  538. AND origin_id = origins.id
  539. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  540. )
  541. ) AS quz__foo1_types__max_time__90days,
  542. (SELECT max(timestamp_col)
  543. FROM events
  544. WHERE (payload->>'type' = 'foo1'
  545. AND category_id = origins.category_id
  546. AND origin_id = origins.id
  547. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  548. )
  549. ) AS quz__foo1_types__max_time__90days,
  550. (SELECT max(timestamp_col)
  551. FROM events
  552. WHERE (payload->>'type' = 'foo1'
  553. AND category_id = origins.category_id
  554. AND origin_id = origins.id
  555. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  556. )
  557. ) AS quz__foo1_types__max_time__90days,
  558. (SELECT max(timestamp_col)
  559. FROM events
  560. WHERE (payload->>'type' = 'foo1'
  561. AND category_id = origins.category_id
  562. AND origin_id = origins.id
  563. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  564. )
  565. ) AS quz__foo1_types__max_time__90days,
  566. (SELECT max(timestamp_col)
  567. FROM events
  568. WHERE (payload->>'type' = 'foo1'
  569. AND category_id = origins.category_id
  570. AND origin_id = origins.id
  571. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  572. )
  573. ) AS quz__foo1_types__max_time__90days,
  574. (SELECT max(timestamp_col)
  575. FROM events
  576. WHERE (payload->>'type' = 'foo1'
  577. AND category_id = origins.category_id
  578. AND origin_id = origins.id
  579. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  580. )
  581. ) AS quz__foo1_types__max_time__90days,
  582. (SELECT max(timestamp_col)
  583. FROM events
  584. WHERE (payload->>'type' = 'foo1'
  585. AND category_id = origins.category_id
  586. AND origin_id = origins.id
  587. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  588. )
  589. ) AS quz__foo1_types__max_time__90days,
  590. (SELECT max(timestamp_col)
  591. FROM events
  592. WHERE (payload->>'type' = 'foo1'
  593. AND category_id = origins.category_id
  594. AND origin_id = origins.id
  595. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  596. )
  597. ) AS quz__foo1_types__max_time__90days,
  598. (SELECT max(timestamp_col)
  599. FROM events
  600. WHERE (payload->>'type' = 'foo1'
  601. AND category_id = origins.category_id
  602. AND origin_id = origins.id
  603. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  604. )
  605. ) AS quz__foo1_types__max_time__90days,
  606. (SELECT max(timestamp_col)
  607. FROM events
  608. WHERE (payload->>'type' = 'foo1'
  609. AND category_id = origins.category_id
  610. AND origin_id = origins.id
  611. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  612. )
  613. ) AS quz__foo1_types__max_time__90days,
  614. (SELECT max(timestamp_col)
  615. FROM events
  616. WHERE (payload->>'type' = 'foo1'
  617. AND category_id = origins.category_id
  618. AND origin_id = origins.id
  619. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  620. )
  621. ) AS quz__foo1_types__max_time__90days,
  622. (SELECT max(timestamp_col)
  623. FROM events
  624. WHERE (payload->>'type' = 'foo1'
  625. AND category_id = origins.category_id
  626. AND origin_id = origins.id
  627. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  628. )
  629. ) AS quz__foo1_types__max_time__90days,
  630. (SELECT max(timestamp_col)
  631. FROM events
  632. WHERE (payload->>'type' = 'foo1'
  633. AND category_id = origins.category_id
  634. AND origin_id = origins.id
  635. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  636. )
  637. ) AS quz__foo1_types__max_time__90days,
  638. (SELECT max(timestamp_col)
  639. FROM events
  640. WHERE (payload->>'type' = 'foo1'
  641. AND category_id = origins.category_id
  642. AND origin_id = origins.id
  643. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  644. )
  645. ) AS quz__foo1_types__max_time__90days,
  646. (SELECT max(timestamp_col)
  647. FROM events
  648. WHERE (payload->>'type' = 'foo1'
  649. AND category_id = origins.category_id
  650. AND origin_id = origins.id
  651. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  652. )
  653. ) AS quz__foo1_types__max_time__90days,
  654. (SELECT max(timestamp_col)
  655. FROM events
  656. WHERE (payload->>'type' = 'foo1'
  657. AND category_id = origins.category_id
  658. AND origin_id = origins.id
  659. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  660. )
  661. ) AS quz__foo1_types__max_time__90days,
  662. (SELECT max(timestamp_col)
  663. FROM events
  664. WHERE (payload->>'type' = 'foo1'
  665. AND category_id = origins.category_id
  666. AND origin_id = origins.id
  667. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  668. )
  669. ) AS quz__foo1_types__max_time__90days,
  670. (SELECT max(timestamp_col)
  671. FROM events
  672. WHERE (payload->>'type' = 'foo1'
  673. AND category_id = origins.category_id
  674. AND origin_id = origins.id
  675. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  676. )
  677. ) AS quz__foo1_types__max_time__90days,
  678. (SELECT max(timestamp_col)
  679. FROM events
  680. WHERE (payload->>'type' = 'foo1'
  681. AND category_id = origins.category_id
  682. AND origin_id = origins.id
  683. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  684. )
  685. ) AS quz__foo1_types__max_time__90days,
  686. (SELECT max(timestamp_col)
  687. FROM events
  688. WHERE (payload->>'type' = 'foo1'
  689. AND category_id = origins.category_id
  690. AND origin_id = origins.id
  691. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  692. )
  693. ) AS quz__foo1_types__max_time__90days,
  694. (SELECT max(timestamp_col)
  695. FROM events
  696. WHERE (payload->>'type' = 'foo1'
  697. AND category_id = origins.category_id
  698. AND origin_id = origins.id
  699. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  700. )
  701. ) AS quz__foo1_types__max_time__90days,
  702. (SELECT max(timestamp_col)
  703. FROM events
  704. WHERE (payload->>'type' = 'foo1'
  705. AND category_id = origins.category_id
  706. AND origin_id = origins.id
  707. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  708. )
  709. ) AS quz__foo1_types__max_time__90days,
  710. (SELECT max(timestamp_col)
  711. FROM events
  712. WHERE (payload->>'type' = 'foo1'
  713. AND category_id = origins.category_id
  714. AND origin_id = origins.id
  715. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  716. )
  717. ) AS quz__foo1_types__max_time__90days,
  718. (SELECT max(timestamp_col)
  719. FROM events
  720. WHERE (payload->>'type' = 'foo1'
  721. AND category_id = origins.category_id
  722. AND origin_id = origins.id
  723. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  724. )
  725. ) AS quz__foo1_types__max_time__90days,
  726. (SELECT max(timestamp_col)
  727. FROM events
  728. WHERE (payload->>'type' = 'foo1'
  729. AND category_id = origins.category_id
  730. AND origin_id = origins.id
  731. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  732. )
  733. ) AS quz__foo1_types__max_time__90days,
  734. (SELECT max(timestamp_col)
  735. FROM events
  736. WHERE (payload->>'type' = 'foo1'
  737. AND category_id = origins.category_id
  738. AND origin_id = origins.id
  739. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  740. )
  741. ) AS quz__foo1_types__max_time__90days,
  742. (SELECT max(timestamp_col)
  743. FROM events
  744. WHERE (payload->>'type' = 'foo1'
  745. AND category_id = origins.category_id
  746. AND origin_id = origins.id
  747. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  748. )
  749. ) AS quz__foo1_types__max_time__90days,
  750. (SELECT max(timestamp_col)
  751. FROM events
  752. WHERE (payload->>'type' = 'foo1'
  753. AND category_id = origins.category_id
  754. AND origin_id = origins.id
  755. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  756. )
  757. ) AS quz__foo1_types__max_time__90days,
  758. (SELECT max(timestamp_col)
  759. FROM events
  760. WHERE (payload->>'type' = 'foo1'
  761. AND category_id = origins.category_id
  762. AND origin_id = origins.id
  763. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  764. )
  765. ) AS quz__foo1_types__max_time__90days,
  766. (SELECT max(timestamp_col)
  767. FROM events
  768. WHERE (payload->>'type' = 'foo1'
  769. AND category_id = origins.category_id
  770. AND origin_id = origins.id
  771. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  772. )
  773. ) AS quz__foo1_types__max_time__90days,
  774. (SELECT max(timestamp_col)
  775. FROM events
  776. WHERE (payload->>'type' = 'foo1'
  777. AND category_id = origins.category_id
  778. AND origin_id = origins.id
  779. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  780. )
  781. ) AS quz__foo1_types__max_time__90days,
  782. (SELECT max(timestamp_col)
  783. FROM events
  784. WHERE (payload->>'type' = 'foo1'
  785. AND category_id = origins.category_id
  786. AND origin_id = origins.id
  787. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  788. )
  789. ) AS quz__foo1_types__max_time__90days,
  790. (SELECT max(timestamp_col)
  791. FROM events
  792. WHERE (payload->>'type' = 'foo1'
  793. AND category_id = origins.category_id
  794. AND origin_id = origins.id
  795. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  796. )
  797. ) AS quz__foo1_types__max_time__90days,
  798. (SELECT max(timestamp_col)
  799. FROM events
  800. WHERE (payload->>'type' = 'foo1'
  801. AND category_id = origins.category_id
  802. AND origin_id = origins.id
  803. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  804. )
  805. ) AS quz__foo1_types__max_time__90days,
  806. (SELECT max(timestamp_col)
  807. FROM events
  808. WHERE (payload->>'type' = 'foo1'
  809. AND category_id = origins.category_id
  810. AND origin_id = origins.id
  811. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  812. )
  813. ) AS quz__foo1_types__max_time__90days,
  814. (SELECT max(timestamp_col)
  815. FROM events
  816. WHERE (payload->>'type' = 'foo1'
  817. AND category_id = origins.category_id
  818. AND origin_id = origins.id
  819. AND mz_now() BETWEEN (1000 * CAST(extract(epoch from timestamp_col) AS numeric)) AND (1000 * CAST(extract(epoch from timestamp_col + interval '90' days) AS numeric))
  820. )
  821. ) AS quz__foo1_types__max_time__90days
  822. FROM
  823. origins;