DROP TABLE qt_slow_gui; EXPLAIN ANALYZE CREATE TABLE "qt_slow_gui" AS ( SELECT "f_zendesktickets_aaeljtllr5at3el"."cstm_custom_38746665_primary_column" AS "a_1199451", COUNT( DISTINCT ( CASE WHEN ( ( "f_ticketattributeshistory_aajzjp98uraszb6"."attrnewvalue_id" IN ( 4757, 4758, 4759 ) ) AND ( 4754 = "f_ticketattributeshistory_aajzjp98uraszb6"."attroldvalue_id" ) AND ( 4790 = "f_ticketattributeshistory_aajzjp98uraszb6"."ticketfield_id" ) ) THEN "f_ticketattributeshistory_aajzjp98uraszb6"."zendesktickets_id" ELSE CAST( NULL AS INT ) END ) ) AS "c_69b347d8c59f8323" , COUNT( DISTINCT ( CASE WHEN ( "f_zendesktickets_aaeljtllr5at3el"."dt_createdat_id" = "f_ticketupdate_aad5jtwal0ayaax"."dt_event_id" ) THEN "f_ticketattributeshistory_aajzjp98uraszb6"."zendesktickets_id" ELSE CAST( NULL AS INT ) END ) ) AS "c_87ffdbc580a27663", ( MAX( ( CASE WHEN ( ( "f_ticketattributeshistory_aajzjp98uraszb6"."attrnewvalue_id" IN ( 4757, 4758, 4759 ) ) AND ( 4754 = "f_ticketattributeshistory_aajzjp98uraszb6"."attroldvalue_id" ) AND ( 4790 = "f_ticketattributeshistory_aajzjp98uraszb6"."ticketfield_id" ) ) THEN 0 END ) ) IS NOT NULL ) AS "def_69b347d8c59f8323", ( MAX( ( CASE WHEN ( "f_zendesktickets_aaeljtllr5at3el"."dt_createdat_id" = "f_ticketupdate_aad5jtwal0ayaax"."dt_event_id" ) THEN 0 END ) ) IS NOT NULL ) AS "def_87ffdbc580a27663" FROM ( ( ( "f_ticketattributeshistory_aajzjp98uraszb6" INNER JOIN "f_zendesktickets_aaeljtllr5at3el" ON ( "f_ticketattributeshistory_aajzjp98uraszb6"."zendesktickets_id" = "f_zendesktickets_aaeljtllr5at3el"."id" ) ) INNER JOIN "f_ticketupdate_aad5jtwal0ayaax" ON ( "f_ticketattributeshistory_aajzjp98uraszb6"."ticketupdate_id" = "f_ticketupdate_aad5jtwal0ayaax"."id" ) ) INNER JOIN "dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61iagl1z" AS "dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia" ON ( "f_ticketupdate_aad5jtwal0ayaax"."dt_event_id" = "dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia"."id" ) ) WHERE ( ( "f_zendesktickets_aaeljtllr5at3el"."group_id" IN ( 17429 ) ) AND ( 4765 <> "f_zendesktickets_aaeljtllr5at3el"."status_id" ) AND ( 6171 = "dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia"."id_euweek" ) AND ( ( ( "f_ticketattributeshistory_aajzjp98uraszb6"."attrnewvalue_id" IN ( 4757, 4758, 4759 ) ) AND ( 4754 = "f_ticketattributeshistory_aajzjp98uraszb6"."attroldvalue_id" ) AND ( 4790 = "f_ticketattributeshistory_aajzjp98uraszb6"."ticketfield_id" ) ) OR ( "f_zendesktickets_aaeljtllr5at3el"."dt_createdat_id" = "f_ticketupdate_aad5jtwal0ayaax"."dt_event_id" ) ) ) GROUP BY 1 ); ---------------------------------------------------------- PG10 - set max_parallel_workers_per_gather=2; GroupAggregate (cost=1949504.45..1949508.47 rows=31 width=22) (actual time=8042.299..8042.299 rows=0 loops=1) Group Key: f_zendesktickets_aaeljtllr5at3el.cstm_custom_38746665_primary_column -> Sort (cost=1949504.45..1949504.70 rows=99 width=28) (actual time=8042.297..8042.297 rows=0 loops=1) Sort Key: f_zendesktickets_aaeljtllr5at3el.cstm_custom_38746665_primary_column Sort Method: quicksort Memory: 25kB -> Gather (cost=528.45..1949501.17 rows=99 width=28) (actual time=8042.291..8042.291 rows=0 loops=1) Workers Planned: 2 Workers Launched: 2 -> Nested Loop (cost=28.45..1948996.22 rows=41 width=28) (actual time=8036.657..8036.657 rows=0 loops=3) Join Filter: (((f_ticketattributeshistory_aajzjp98uraszb6.attrnewvalue_id = ANY ('{4757,4758,4759}'::integer[])) AND (4754 = f_ticketattributeshistory_aajzjp98uraszb6.attroldvalue_id) AND (4790 = f_ticketattributeshistory_aajzjp98uraszb6.ticketfield_id)) OR (f_zendesktickets_aaeljtllr5at3el.dt_cr eatedat_id = f_ticketupdate_aad5jtwal0ayaax.dt_event_id)) -> Nested Loop (cost=28.01..1614993.67 rows=145946 width=20) (actual time=8036.656..8036.656 rows=0 loops=3) -> Hash Join (cost=27.44..1489550.83 rows=28808 width=8) (actual time=8036.655..8036.655 rows=0 loops=3) Hash Cond: (f_ticketupdate_aad5jtwal0ayaax.dt_event_id = dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia.id) -> Parallel Seq Scan on f_ticketupdate_aad5jtwal0ayaax (cost=0.00..1185867.47 rows=24054847 width=8) (actual time=0.020..3741.409 rows=19243863 loops=3) -> Hash (cost=27.35..27.35 rows=7 width=4) (actual time=0.089..0.089 rows=7 loops=3) Buckets: 1024 Batches: 1 Memory Usage: 9kB -> Bitmap Heap Scan on dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61iagl1z dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia (cost=4.34..27.35 rows=7 width=4) (actual time=0.046..0.082 rows=7 loops=3) Recheck Cond: (6171 = id_euweek) Heap Blocks: exact=7 -> Bitmap Index Scan on dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_a_id_euweek_idx (cost=0.00..4.33 rows=7 width=0) (actual time=0.029..0.029 rows=7 loops=3) Index Cond: (6171 = id_euweek) -> Index Scan using f_ticketattributeshistory_aajzjp98uraszb6_ticketupdate_id_idx on f_ticketattributeshistory_aajzjp98uraszb6 (cost=0.57..4.12 rows=23 width=20) (never executed) Index Cond: (ticketupdate_id = f_ticketupdate_aad5jtwal0ayaax.id) -> Index Scan using f_zendesktickets_aaeljtllr5at3el_pkey on f_zendesktickets_aaeljtllr5at3el (cost=0.43..2.27 rows=1 width=12) (never executed) Index Cond: (id = f_ticketattributeshistory_aajzjp98uraszb6.zendesktickets_id) Filter: ((4765 <> status_id) AND (group_id = 17429)) Planning time: 7.822 ms Execution time: 8132.851 ms (28 rows) ---------------------------------------------------------- PG 10 -set max_parallel_workers_per_gather=0; GroupAggregate (cost=2611148.87..2611152.89 rows=31 width=22) (actual time=0.071..0.071 rows=0 loops=1) Group Key: f_zendesktickets_aaeljtllr5at3el.cstm_custom_38746665_primary_column -> Sort (cost=2611148.87..2611149.11 rows=99 width=28) (actual time=0.070..0.070 rows=0 loops=1) Sort Key: f_zendesktickets_aaeljtllr5at3el.cstm_custom_38746665_primary_column Sort Method: quicksort Memory: 25kB -> Nested Loop (cost=1639.25..2611145.59 rows=99 width=28) (actual time=0.057..0.057 rows=0 loops=1) Join Filter: (((f_ticketattributeshistory_aajzjp98uraszb6.attrnewvalue_id = ANY ('{4757,4758,4759}'::integer[])) AND (4754 = f_ticketattributeshistory_aajzjp98uraszb6.attroldvalue_id) AND (4790 = f_ticketattributeshistory_aajzjp98uraszb6.ticketfield_id)) OR (f_zendesktickets_aaeljtllr5at3el.dt_createda t_id = f_ticketupdate_aad5jtwal0ayaax.dt_event_id)) -> Nested Loop (cost=1638.81..1809540.39 rows=350270 width=20) (actual time=0.057..0.057 rows=0 loops=1) -> Nested Loop (cost=1638.24..1508474.08 rows=69140 width=8) (actual time=0.057..0.057 rows=0 loops=1) -> Bitmap Heap Scan on dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61iagl1z dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia (cost=4.34..27.35 rows=7 width=4) (actual time=0.018..0.029 rows=7 loops=1) Recheck Cond: (6171 = id_euweek) Heap Blocks: exact=7 -> Bitmap Index Scan on dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_a_id_euweek_idx (cost=0.00..4.33 rows=7 width=0) (actual time=0.012..0.012 rows=7 loops=1) Index Cond: (6171 = id_euweek) -> Bitmap Heap Scan on f_ticketupdate_aad5jtwal0ayaax (cost=1633.90..214617.67 rows=87472 width=8) (actual time=0.002..0.002 rows=0 loops=7) Recheck Cond: (dt_event_id = dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia.id) -> Bitmap Index Scan on f_ticketupdate_aad5jtwal0ayaax_dt_event_id_idx (cost=0.00..1612.03 rows=87472 width=0) (actual time=0.002..0.002 rows=0 loops=7) Index Cond: (dt_event_id = dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia.id) -> Index Scan using f_ticketattributeshistory_aajzjp98uraszb6_ticketupdate_id_idx on f_ticketattributeshistory_aajzjp98uraszb6 (cost=0.57..4.12 rows=23 width=20) (never executed) Index Cond: (ticketupdate_id = f_ticketupdate_aad5jtwal0ayaax.id) -> Index Scan using f_zendesktickets_aaeljtllr5at3el_pkey on f_zendesktickets_aaeljtllr5at3el (cost=0.43..2.27 rows=1 width=12) (never executed) Index Cond: (id = f_ticketattributeshistory_aajzjp98uraszb6.zendesktickets_id) Filter: ((4765 <> status_id) AND (group_id = 17429)) Planning time: 7.610 ms Execution time: 1.057 ms (25 rows) ---------------------------------------------------------- PG 9.5: GroupAggregate (cost=1212827.98..1212831.77 rows=4 width=28) (actual time=77.419..77.419 rows=0 loops=1) Group Key: f_zendesktickets_aaeljtllr5at3el.cstm_custom_38746665_primary_column -> Sort (cost=1212827.98..1212828.23 rows=100 width=28) (actual time=77.413..77.413 rows=0 loops=1) Sort Key: f_zendesktickets_aaeljtllr5at3el.cstm_custom_38746665_primary_column Sort Method: quicksort Memory: 25kB -> Nested Loop (cost=5.91..1212824.66 rows=100 width=28) (actual time=77.368..77.368 rows=0 loops=1) Join Filter: (((f_ticketattributeshistory_aajzjp98uraszb6.attrnewvalue_id = ANY ('{4757,4758,4759}'::integer[])) AND (4754 = f_ticketattributeshistory_aajzjp98uraszb6.attroldvalue_id) AND (4790 = f_ticketattributeshistory_aajzjp98uraszb6.ticketfield_id)) OR (f_zendesktickets_aaeljtllr5at3el.dt_createdat_id = f_ticketupdate_aad5jtwal0ayaax.dt_event_id)) -> Nested Loop (cost=5.47..411219.46 rows=350270 width=20) (actual time=77.366..77.366 rows=0 loops=1) -> Nested Loop (cost=4.90..107167.24 rows=69140 width=8) (actual time=77.365..77.365 rows=0 loops=1) -> Bitmap Heap Scan on dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61iagl1z dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia (cost=4.34..27.35 rows=7 width=4) (actual time=27.785..77.233 rows=7 loops=1) Recheck Cond: (6171 = id_euweek) Heap Blocks: exact=7 -> Bitmap Index Scan on dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_a_id_euweek_idx (cost=0.00..4.33 rows=7 width=0) (actual time=18.983..18.983 rows=7 loops=1) Index Cond: (6171 = id_euweek) -> Index Scan using f_ticketupdate_aad5jtwal0ayaax_dt_event_id_idx on f_ticketupdate_aad5jtwal0ayaax (cost=0.56..14432.30 rows=87340 width=8) (actual time=0.012..0.012 rows=0 loops=7) Index Cond: (dt_event_id = dwh_dm_aabv5kk9rxac4lz_aaonw7nchsan2n1_aad8xhr0m_aaewg8j61ia.id) -> Index Scan using f_ticketattributeshistory_aajzjp98uraszb6_ticketupdate_id_idx on f_ticketattributeshistory_aajzjp98uraszb6 (cost=0.57..4.16 rows=24 width=20) (never executed) Index Cond: (ticketupdate_id = f_ticketupdate_aad5jtwal0ayaax.id) -> Index Scan using f_zendesktickets_aaeljtllr5at3el_pkey on f_zendesktickets_aaeljtllr5at3el (cost=0.43..2.27 rows=1 width=12) (never executed) Index Cond: (id = f_ticketattributeshistory_aajzjp98uraszb6.zendesktickets_id) Filter: ((4765 <> status_id) AND (group_id = 17429)) Planning time: 8.301 ms Execution time: 20.217 ms (23 rows)