# Result: 7py4 : Optimization for: Optimization for: plan #DR4m; plan #jBti

Settings

### Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 3,806.619 19,245.034 ↓ 7.1 85,367 1

(cost=3,464,329.68..3,668,499.76 rows=12,104 width=1,843) (actual time=15,336.52..19,245.034 rows=85,367 loops=1)

2. 85.094 10,597.117 ↓ 7.1 85,367 1

(cost=1,763,060.9..1,763,091.16 rows=12,104 width=783) (actual time=10,579.367..10,597.117 rows=85,367 loops=1)

• Sort Key: b.id
• Sort Method: quicksort Memory: 26,879kB
3. 49.291 10,512.023 ↓ 7.1 85,367 1

(cost=1,743,988.38..1,762,240.06 rows=12,104 width=783) (actual time=9,837.22..10,512.023 rows=85,367 loops=1)

4. 27.759 1,029.523 ↓ 7.1 85,367 1

(cost=33,013.02..51,232.93 rows=12,104 width=775) (actual time=403.991..1,029.523 rows=85,367 loops=1)

5. 30.414 993.957 ↓ 7.1 85,367 1

(cost=31,651.07..49,838.95 rows=12,104 width=755) (actual time=396.173..993.957 rows=85,367 loops=1)

6. 32.696 962.983 ↓ 7.1 85,367 1

(cost=31,606.15..49,762.16 rows=12,104 width=744) (actual time=395.599..962.983 rows=85,367 loops=1)

7. 32.562 930.266 ↓ 7.1 85,367 1

(cost=31,604.66..49,722.78 rows=12,104 width=232) (actual time=395.569..930.266 rows=85,367 loops=1)

8. 30.091 897.657 ↓ 7.1 85,367 1

(cost=31,601.74..49,687.67 rows=12,104 width=221) (actual time=395.507..897.657 rows=85,367 loops=1)

9. 159.738 611.465 ↓ 7.1 85,367 1

(cost=31,601.32..43,300.04 rows=12,104 width=171) (actual time=395.455..611.465 rows=85,367 loops=1)

10. 57.365 57.365 ↓ 1.0 403,774 1

Seq Scan on checkout_batch_unity cbu (cost=0..8,671.37 rows=403,637 width=38) (actual time=0.037..57.365 rows=403,774 loops=1)

11. 39.412 394.362 ↓ 7.1 85,367 1

(cost=31,419.76..31,419.76 rows=12,104 width=145) (actual time=394.362..394.362 rows=85,367 loops=1)

• Buffers: shared hit=19,440
12. 34.129 354.950 ↓ 7.1 85,367 1

(cost=1,920.79..31,419.76 rows=12,104 width=145) (actual time=4.742..354.95 rows=85,367 loops=1)

• Buffers: shared hit=19,440
13. 194.007 320.189 ↑ 2.2 85,367 1

(cost=1,178.23..29,855.3 rows=186,889 width=110) (actual time=4.102..320.189 rows=85,367 loops=1)

• Buffers: shared hit=18,822
14. 122.105 122.105 ↓ 1.0 865,855 1

Seq Scan on batchunity b (cost=0..26,403.14 rows=865,714 width=83) (actual time=0.005..122.105 rows=865,855 loops=1)

• Buffers: shared hit=17,746
15. 0.333 4.077 ↑ 1.0 1,452 1

(cost=1,160.08..1,160.08 rows=1,452 width=35) (actual time=4.077..4.077 rows=1,452 loops=1)

• Buffers: shared hit=1,076
16. 3.744 3.744 ↑ 1.0 1,452 1

Seq Scan on batch bt (cost=0..1,160.08 rows=1,452 width=35) (actual time=0.082..3.744 rows=1,452 loops=1)

• Filter: (bt.company_id = 501)
• Buffers: shared hit=1,076
17. 0.035 0.632 ↓ 1.1 97 1

(cost=741.45..741.45 rows=89 width=43) (actual time=0.631..0.632 rows=97 loops=1)

• Buffers: shared hit=618
18. 0.060 0.597 ↓ 1.1 97 1

(cost=3.28..741.45 rows=89 width=43) (actual time=0.07..0.597 rows=97 loops=1)

• Buffers: shared hit=618
19. 0.246 0.246 ↑ 1.0 97 1

Index Scan using subarea_pkey on subarea cs (cost=0.28..60.8 rows=97 width=19) (actual time=0.033..0.246 rows=97 loops=1)

• Index Cond: (cs.id = ANY ('{1051,1201,801,851,800,2817,4110,4111,4112,11404,2805,11408,10538,14255,2802,2812,2706,6812,7380,7381,13154,10457,2853,2810,2813,2811,2814,2854,2705,4108,6250,10675,7385,2803,11796,11407,2820,4654,8503,9552,2818,13057,11405,11406,8569,2819,751,10674,13102,2816,2815,2807,2804,2806,10673,12802,12803,12804,12805,12815,12806,12807,12808,12809,12810,12811,12812,12816,12813,12814,1101,1301,901,1251,1151,1001,951,10352,10353,9804,2823,2808,2809,11797,2824,2822,4657,4109,3503,2825,1756,2821,10402,10403,11452,2752,7402}'::integer[]))
• Buffers: shared hit=230
20. 0.194 0.291 ↑ 1.0 1 97

Bitmap Heap Scan on accountable acc (cost=3..7.02 rows=1 width=28) (actual time=0.003..0.003 rows=1 loops=97)

• Filter: acc.active
• Heap Blocks: exact=97
• Buffers: shared hit=388
21. 0.097 0.097 ↑ 1.0 1 97

Bitmap Index Scan on accountable_pkey (cost=0..3 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=97)

• Index Cond: (acc.id = cs.accountable_id)
• Buffers: shared hit=291
22. 256.101 256.101 ↑ 1.0 1 85,367

Index Scan using batchunity_detail_pkey on batchunity_detail bd (cost=0.42..0.53 rows=1 width=54) (actual time=0.003..0.003 rows=1 loops=85,367)

• Index Cond: (bd.batchunity_id = b.id)
23. 0.027 0.047 ↓ 1.2 100 1

(cost=1.85..1.85 rows=85 width=19) (actual time=0.046..0.047 rows=100 loops=1)

• Buffers: shared hit=1
24. 0.020 0.020 ↓ 1.2 100 1

Seq Scan on batchunitystatus bus (cost=0..1.85 rows=85 width=19) (actual time=0.006..0.02 rows=100 loops=1)

• Buffers: shared hit=1
25. 0.008 0.021 ↓ 1.1 24 1

(cost=1.22..1.22 rows=22 width=520) (actual time=0.021..0.021 rows=24 loops=1)

• Buffers: shared hit=1
26. 0.013 0.013 ↓ 1.1 24 1

Seq Scan on batchunityeventtype buevt (cost=0..1.22 rows=22 width=520) (actual time=0.009..0.013 rows=24 loops=1)

• Buffers: shared hit=1
27. 0.288 0.560 ↑ 1.0 1,336 1

(cost=27.74..27.74 rows=1,374 width=19) (actual time=0.56..0.56 rows=1,336 loops=1)

28. 0.272 0.272 ↑ 1.0 1,336 1

Seq Scan on subarea cs_lastevent (cost=0..27.74 rows=1,374 width=19) (actual time=0.005..0.272 rows=1,336 loops=1)

29. 0.114 7.807 ↑ 1.0 511 1

(cost=1,355.57..1,355.57 rows=511 width=28) (actual time=7.807..7.807 rows=511 loops=1)

30. 7.693 7.693 ↑ 1.0 511 1

Seq Scan on accountable acc_lastevent (cost=0..1,355.57 rows=511 width=28) (actual time=0.005..7.693 rows=511 loops=1)

• Filter: acc_lastevent.active
31. 11.841 9,433.209 ↓ 327.1 65,425 1

(cost=1,710,972.86..1,710,972.86 rows=200 width=12) (actual time=9,433.209..9,433.209 rows=65,425 loops=1)

32. 8.968 9,421.368 ↓ 327.1 65,425 1

Subquery Scan on event_collect (cost=1,710,968.86..1,710,972.86 rows=200 width=12) (actual time=9,397.766..9,421.368 rows=65,425 loops=1)

33. 1,550.086 9,412.400 ↓ 327.1 65,425 1

(cost=1,710,968.86..1,710,970.86 rows=200 width=12) (actual time=9,397.765..9,412.4 rows=65,425 loops=1)

• Group Key: bh.batchunity_id
34. 491.457 7,862.314 ↓ 2.5 4,725,314 1

(cost=0..1,701,459.38 rows=1,901,895 width=12) (actual time=2.635..7,862.314 rows=4,725,314 loops=1)

35. 0.003 0.003 ↓ 0.0 0 1

Seq Scan on batchunityhistory_part bh (cost=0..0 rows=1 width=12) (actual time=0.003..0.003 rows=0 loops=1)

• Filter: ((bh.eventtype_id = ANY ('{2,4}'::integer[])) AND (bh.subarea_id = 2,706))
36. 284.102 284.102 ↓ 1.7 209,041 1

Seq Scan on batchunityhistory_part_2017 bh_1 (cost=0..35,657.26 rows=120,979 width=12) (actual time=2.632..284.102 rows=209,041 loops=1)

• Filter: ((bh_1.eventtype_id = ANY ('{2,4}'::integer[])) AND (bh_1.subarea_id = 2,706))
37. 1,514.013 1,883.796 ↓ 2.3 1,751,925 1

Bitmap Heap Scan on batchunityhistory_part_2018 bh_2 (cost=114,998.25..410,429.74 rows=746,551 width=12) (actual time=408.318..1,883.796 rows=1,751,925 loops=1)

• Filter: (bh_2.subarea_id = 2,706)
• Heap Blocks: exact=84,688
38. 369.783 369.783 ↓ 1.0 6,942,989 1

Bitmap Index Scan on history_part_2018_eventtype_id_idx (cost=0..114,811.61 rows=6,934,766 width=0) (actual time=369.783..369.783 rows=6,942,989 loops=1)

• Index Cond: (bh_2.eventtype_id = ANY ('{2,4}'::integer[]))
39. 3,321.418 4,096.437 ↓ 2.4 1,830,486 1

Bitmap Heap Scan on batchunityhistory_part_2019 bh_3 (cost=242,028.83..937,993.49 rows=751,480 width=12) (actual time=831.893..4,096.437 rows=1,830,486 loops=1)

• Filter: (bh_3.subarea_id = 2,706)
• Heap Blocks: exact=217,453
40. 775.019 775.019 ↑ 1.0 14,574,857 1

Bitmap Index Scan on history_part_2019_eventtype_id_idx (cost=0..241,840.96 rows=14,578,644 width=0) (actual time=775.019..775.019 rows=14,574,857 loops=1)

• Index Cond: (bh_3.eventtype_id = ANY ('{2,4}'::integer[]))
41. 877.459 1,106.519 ↓ 3.3 933,862 1

Bitmap Heap Scan on batchunityhistory_part_2020 bh_4 (cost=77,234.69..317,378.89 rows=282,884 width=12) (actual time=242.325..1,106.519 rows=933,862 loops=1)

• Filter: (bh_4.subarea_id = 2,706)
• Heap Blocks: exact=69,259
42. 229.060 229.060 ↓ 1.0 4,127,242 1

Bitmap Index Scan on history_part_2020_eventtype_id_idx (cost=0..77,163.97 rows=4,062,280 width=0) (actual time=229.06..229.06 rows=4,127,242 loops=1)

• Index Cond: (bh_4.eventtype_id = ANY ('{2,4}'::integer[]))
43. 0.001 4,755.931 ↓ 0.0 0 1

(cost=1,701,268.78..1,701,302.37 rows=200 width=12) (actual time=4,755.931..4,755.931 rows=0 loops=1)

• Group Key: bh_5.batchunity_id
44. 0.010 4,755.930 ↓ 0.0 0 1

(cost=1,701,268.78..1,701,279.31 rows=4,212 width=12) (actual time=4,755.93..4,755.93 rows=0 loops=1)

• Sort Key: bh_5.batchunity_id
• Sort Method: quicksort Memory: 25kB
45. 0.006 4,755.920 ↓ 0.0 0 1

(cost=0..1,701,015.21 rows=4,212 width=12) (actual time=4,755.92..4,755.92 rows=0 loops=1)

46. 0.005 0.005 ↓ 0.0 0 1

Seq Scan on batchunityhistory_part bh_5 (cost=0..0 rows=1 width=12) (actual time=0.005..0.005 rows=0 loops=1)

• Filter: ((bh_5.eventtype_id = ANY ('{2,4}'::integer[])) AND (bh_5.subarea_id = 4,654))
47. 192.838 192.838 ↓ 0.0 0 1

Seq Scan on batchunityhistory_part_2017 bh_6 (cost=0..35,657.26 rows=5 width=12) (actual time=192.838..192.838 rows=0 loops=1)

• Filter: ((bh_6.eventtype_id = ANY ('{2,4}'::integer[])) AND (bh_6.subarea_id = 4,654))
• Buffers: shared hit=15,442
48. 892.221 1,170.662 ↓ 0.0 0 1

Bitmap Heap Scan on batchunityhistory_part_2018 bh_7 (cost=114,811.85..410,243.34 rows=933 width=12) (actual time=1,170.662..1,170.662 rows=0 loops=1)

• Filter: (bh_7.subarea_id = 4,654)
• Heap Blocks: exact=84,688
49. 278.441 278.441 ↓ 1.0 6,942,989 1

Bitmap Index Scan on history_part_2018_eventtype_id_idx (cost=0..114,811.61 rows=6,934,766 width=0) (actual time=278.441..278.441 rows=6,942,989 loops=1)

• Index Cond: (bh_7.eventtype_id = ANY ('{2,4}'::integer[]))
50. 2,024.701 2,636.865 ↓ 0.0 0 1

Bitmap Heap Scan on batchunityhistory_part_2019 bh_8 (cost=241,841.56..937,806.22 rows=2,399 width=12) (actual time=2,636.865..2,636.865 rows=0 loops=1)

• Filter: (bh_8.subarea_id = 4,654)
• Heap Blocks: exact=217,453
• Buffers: shared hit=257,284
51. 612.164 612.164 ↑ 1.0 14,574,857 1

Bitmap Index Scan on history_part_2019_eventtype_id_idx (cost=0..241,840.96 rows=14,578,644 width=0) (actual time=612.164..612.164 rows=14,574,857 loops=1)

• Index Cond: (bh_8.eventtype_id = ANY ('{2,4}'::integer[]))
• Buffers: shared hit=39,831
52. 577.739 755.544 ↓ 0.0 0 1

Bitmap Heap Scan on batchunityhistory_part_2020 bh_9 (cost=77,164.19..317,308.39 rows=874 width=12) (actual time=755.544..755.544 rows=0 loops=1)

• Filter: (bh_9.subarea_id = 4,654)
• Heap Blocks: exact=69,259
• Buffers: shared hit=82,682
53. 177.805 177.805 ↓ 1.0 4,127,242 1

Bitmap Index Scan on history_part_2020_eventtype_id_idx (cost=0..77,163.97 rows=4,062,280 width=0) (actual time=177.805..177.805 rows=4,127,242 loops=1)

• Index Cond: (bh_9.eventtype_id = ANY ('{2,4}'::integer[]))
• Buffers: shared hit=13,423
54.

SubPlan (for Merge Join)

55. 85.367 85.367 ↓ 0.0 0 85,367

Index Scan using employee_pk on employee e (cost=0.29..8.3 rows=1 width=27) (actual time=0.001..0.001 rows=0 loops=85,367)

• Index Cond: (e.id = bd.possession_employee_id)
• Buffers: shared hit=69,887
56. 0.000 0.000 ↓ 0.0 0 85,367

Index Scan using employee_pk on employee e_1 (cost=0.29..8.3 rows=1 width=27) (actual time=0..0 rows=0 loops=85,367)

• Index Cond: (e_1.id = bd.dedicated_employee_id)
Planning time Execution time : 11.365 ms : 19,258.546 ms