                                                                                                         QUERY PLAN                                                                                                          
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Finalize Aggregate  (cost=424803.70..424803.71 rows=1 width=8) (actual time=143020.230..161567.872 rows=1 loops=1)
   ->  Gather  (cost=424803.48..424803.69 rows=2 width=8) (actual time=142964.457..161567.851 rows=3 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         ->  Partial Aggregate  (cost=423803.48..423803.49 rows=1 width=8) (actual time=142963.280..142968.559 rows=1 loops=3)
               ->  Parallel Hash Join  (cost=338640.72..421783.68 rows=807919 width=4) (actual time=142746.820..142933.580 rows=1523232 loops=3)
                     Hash Cond: (attachments.folder_id = folders.id)
                     ->  Parallel Seq Scan on attachments  (cost=0.00..54748.97 rows=1980177 width=8) (actual time=0.233..85.380 rows=1576685 loops=3)
                           Filter: (NOT is_deleted)
                           Rows Removed by Filter: 327767
                     ->  Parallel Hash  (cost=329694.99..329694.99 rows=545258 width=4) (actual time=142532.861..142538.136 rows=1030633 loops=3)
                           Buckets: 262144  Batches: 16  Memory Usage: 9664kB
                           ->  Parallel Hash Right Join  (cost=228094.50..329694.99 rows=545258 width=4) (actual time=48620.655..142449.984 rows=1030633 loops=3)
                                 Hash Cond: (contributions.id = folders.contribution_id)
                                 Filter: (NOT COALESCE(sessions.is_deleted, contributions.is_deleted, subcontributions.is_deleted, false))
                                 Rows Removed by Filter: 5283
                                 ->  Parallel Seq Scan on contributions  (cost=0.00..61461.31 rows=2674131 width=5) (actual time=0.034..149.134 rows=2139359 loops=3)
                                 ->  Parallel Hash  (cost=209138.05..209138.05 rows=1090516 width=10) (actual time=22774.998..22775.308 rows=1035916 loops=3)
                                       Buckets: 262144 (originally 262144)  Batches: 262144 (originally 32)  Memory Usage: 19168kB
                                       ->  Parallel Hash Left Join  (cost=115722.60..209138.05 rows=1090516 width=10) (actual time=542.858..617.491 rows=1035916 loops=3)
                                             Hash Cond: (folders.session_id = sessions.id)
                                             ->  Parallel Hash Left Join  (cost=105930.64..184862.48 rows=1090516 width=13) (actual time=412.124..472.199 rows=1035916 loops=3)
                                                   Hash Cond: (folders.subcontribution_id = subcontributions.id)
                                                   Filter: ((contributions_1.is_deleted IS NULL) OR (NOT contributions_1.is_deleted))
                                                   Rows Removed by Filter: 150
                                                   ->  Parallel Hash Join  (cost=23682.51..85276.38 rows=1163755 width=16) (actual time=158.760..242.455 rows=1036066 loops=3)
                                                         Hash Cond: (folders.event_id = events.id)
                                                         ->  Parallel Seq Scan on folders  (cost=0.00..40321.07 rows=1331730 width=20) (actual time=0.009..58.211 rows=1064701 loops=3)
                                                               Filter: ((NOT is_deleted) AND (link_type <> 1))
                                                               Rows Removed by Filter: 4424
                                                         ->  Parallel Hash  (cost=14575.53..14575.53 rows=555039 width=4) (actual time=40.413..40.418 rows=444370 loops=3)
                                                               Buckets: 262144  Batches: 16  Memory Usage: 5344kB
                                                               ->  Parallel Seq Scan on events  (cost=0.00..14575.53 rows=555039 width=4) (actual time=0.009..19.095 rows=444370 loops=3)
                                                                     Filter: (NOT is_deleted)
                                                                     Rows Removed by Filter: 63752
                                                   ->  Parallel Hash  (cost=76907.44..76907.44 rows=325495 width=6) (actual time=119.187..119.190 rows=184447 loops=3)
                                                         Buckets: 262144  Batches: 4  Memory Usage: 8576kB
                                                         ->  Nested Loop Left Join  (cost=0.44..76907.44 rows=325495 width=6) (actual time=0.026..105.242 rows=184447 loops=3)
                                                               ->  Parallel Seq Scan on subcontributions  (cost=0.00..6294.95 rows=325495 width=9) (actual time=0.002..6.771 rows=184447 loops=3)
                                                               ->  Memoize  (cost=0.44..0.84 rows=1 width=5) (actual time=0.000..0.000 rows=1 loops=553341)
                                                                     Cache Key: subcontributions.contribution_id
                                                                     Cache Mode: logical
                                                                     Hits: 123894  Misses: 44462  Evictions: 0  Overflows: 0  Memory Usage: 4690kB
                                                                     Worker 0:  Hits: 142773  Misses: 49442  Evictions: 0  Overflows: 0  Memory Usage: 5215kB
                                                                     Worker 1:  Hits: 142496  Misses: 50274  Evictions: 0  Overflows: 0  Memory Usage: 5303kB
                                                                     ->  Index Scan using pk_contributions on contributions contributions_1  (cost=0.43..0.83 rows=1 width=5) (actual time=0.001..0.001 rows=1 loops=144178)
                                                                           Index Cond: (id = subcontributions.contribution_id)
                                             ->  Parallel Hash  (cost=5715.98..5715.98 rows=248398 width=5) (actual time=20.697..20.698 rows=198719 loops=3)
                                                   Buckets: 262144  Batches: 4  Memory Usage: 7936kB
                                                   ->  Parallel Seq Scan on sessions  (cost=0.00..5715.98 rows=248398 width=5) (actual time=0.003..7.165 rows=198719 loops=3)
 Planning Time: 1.446 ms
 Execution Time: 161571.400 ms
(52 rows)
