explain.depesz.com

PostgreSQL's explain analyze made readable

Result: lJfb

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 65,520.584 ↓ 0.0 0 1

GroupAggregate (cost=8,901.87..8,901.93 rows=1 width=48) (actual time=65,520.584..65,520.584 rows=0 loops=1)

  • Output: param.contract_item_id, sum((((fi.quantity * (tuomc.rate / suomc.rate)) / ((upper(fi.date_range) - lower(fi.date_range)))::numeric) * ((upper((fi.date_range * param.date_range)) - lower((fi.date_range * param.date_range))))::numeric))
  • Group Key: param.contract_item_id
  • Buffers: shared hit=70,188 read=62, temp read=598,181 written=1,096,097
  • I/O Timings: read=0.746
2.          

CTE param

3. 3,221.293 4,982.755 ↓ 140.5 22,507,830 1

Nested Loop (cost=935.10..4,388.68 rows=160,228 width=78) (actual time=70.856..4,982.755 rows=22,507,830 loops=1)

  • Output: contract_product_materialized.product_id, cmp.company_id, crv.date_range, contract_product_materialized.contract_item_id, contract_product_materialized.uom_type_id
  • Buffers: shared hit=70,183
4. 6.620 6.858 ↓ 2.5 2,397 1

Bitmap Heap Scan on client_kronos.contract_product_materialized (cost=47.13..1,486.90 rows=977 width=64) (actual time=0.247..6.858 rows=2,397 loops=1)

  • Output: contract_product_materialized.contract_item_id, contract_product_materialized.contract_id, contract_product_materialized.product_id, contract_product_materialized.estimated_quantity, contract_product_materialized.uom_type_id, contract_product_materialized.rebate_deviated_value, contract_product_materialized.rebate_deviated_type, contract_product_materialized.inactive_override, contract_product_materialized.rebate_direct_value, contract_product_materialized.rebate_direct_type, contract_product_materialized.rebate_direct_decimal_model, contract_product_materialized.rebate_deviated_decimal_model, contract_product_materialized.won, contract_product_materialized.rebate_growth_type, contract_product_materialized.rebate_growth_decimal_model, contract_product_materialized.lift_quantity
  • Recheck Cond: (contract_product_materialized.contract_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid)
  • Heap Blocks: exact=47
  • Buffers: shared hit=151
5. 0.238 0.238 ↓ 2.5 2,397 1

Bitmap Index Scan on contract_product_materialized_pkey (cost=0.00..46.88 rows=977 width=0) (actual time=0.238..0.238 rows=2,397 loops=1)

  • Index Cond: (contract_product_materialized.contract_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid)
  • Buffers: shared hit=104
6. 1,680.164 1,754.604 ↓ 57.3 9,390 2,397

Materialize (cost=887.97..899.34 rows=164 width=46) (actual time=0.030..0.732 rows=9,390 loops=2,397)

  • Output: cav.contract_amend_version_id, crv.date_range, cmp.company_id
  • Buffers: shared hit=70,032
7. 1.208 74.440 ↓ 57.3 9,390 1

Nested Loop (cost=887.97..898.52 rows=164 width=46) (actual time=70.604..74.440 rows=9,390 loops=1)

  • Output: cav.contract_amend_version_id, crv.date_range, cmp.company_id
  • Buffers: shared hit=70,032
8. 0.002 0.028 ↑ 1.0 1 1

Nested Loop (cost=0.56..6.60 rows=1 width=30) (actual time=0.019..0.028 rows=1 loops=1)

  • Output: cav.contract_amend_version_id, crv.date_range
  • Inner Unique: true
  • Buffers: shared hit=6
9. 0.018 0.018 ↑ 1.0 1 1

Index Scan using contract_amend_version_pkey on client_kronos.contract_amend_version cav (cost=0.28..3.30 rows=1 width=32) (actual time=0.009..0.018 rows=1 loops=1)

  • Output: cav.contract_amend_version_id, cav.contract_renew_version_id, cav.contract_state, cav.contract_amend_version_parent_id, cav.contract_name, cav.contact_name, cav.contact_email, cav.contact_phone, cav.create_timestamp, cav.amend_version
  • Index Cond: (cav.contract_amend_version_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid)
  • Buffers: shared hit=3
10. 0.008 0.008 ↑ 1.0 1 1

Index Scan using contract_version_pkey on client_kronos.contract_renew_version crv (cost=0.28..3.30 rows=1 width=30) (actual time=0.008..0.008 rows=1 loops=1)

  • Output: crv.contract_renew_version_id, crv.contract_family_id, crv.date_range, crv.create_timestamp, crv.dead, crv.renew_version
  • Index Cond: (crv.contract_renew_version_id = cav.contract_renew_version_id)
  • Buffers: shared hit=3
11. 1.953 73.204 ↓ 57.3 9,390 1

Unique (cost=887.40..888.63 rows=164 width=36) (actual time=70.584..73.204 rows=9,390 loops=1)

  • Output: cav_1.contract_amend_version_id, cmp.company_id, ct.internal_company_type
  • Buffers: shared hit=70,026
12. 4.620 71.251 ↓ 62.8 10,305 1

Sort (cost=887.40..887.81 rows=164 width=36) (actual time=70.582..71.251 rows=10,305 loops=1)

  • Output: cav_1.contract_amend_version_id, cmp.company_id, ct.internal_company_type
  • Sort Key: cmp.company_id, ct.internal_company_type
  • Sort Method: quicksort Memory: 1,190kB
  • Buffers: shared hit=70,026
13. 3.136 66.631 ↓ 62.8 10,305 1

Hash Join (cost=360.03..881.37 rows=164 width=36) (actual time=0.149..66.631 rows=10,305 loops=1)

  • Output: cav_1.contract_amend_version_id, cmp.company_id, ct.internal_company_type
  • Inner Unique: true
  • Hash Cond: (cmp.company_type_id = ct.company_type_id)
  • Buffers: shared hit=70,021
14. 0.353 63.485 ↓ 62.8 10,305 1

Nested Loop (cost=358.98..878.98 rows=164 width=48) (actual time=0.132..63.485 rows=10,305 loops=1)

  • Output: cav_1.contract_amend_version_id, cmp.company_id, cmp.company_type_id
  • Inner Unique: true
  • Buffers: shared hit=70,020
15. 0.000 42.522 ↓ 58.6 10,305 1

Nested Loop (cost=358.70..818.72 rows=176 width=32) (actual time=0.122..42.522 rows=10,305 loops=1)

  • Output: cav_1.contract_amend_version_id, cagg.agg_company_id
  • Buffers: shared hit=39,066
16. 1.303 22.941 ↓ 58.4 10,224 1

Nested Loop Left Join (cost=358.29..663.13 rows=175 width=48) (actual time=0.105..22.941 rows=10,224 loops=1)

  • Output: c.contractee_company_id, cav_1.contract_amend_version_id, cg_1.company_id
  • Buffers: shared hit=7,971
17. 0.037 0.453 ↓ 19.0 19 1

Hash Right Join (cost=357.87..373.54 rows=1 width=48) (actual time=0.045..0.453 rows=19 loops=1)

  • Output: c.contractee_company_id, cav_1.contract_amend_version_id, groupings_list.grouping_id
  • Hash Cond: (groupings_list.original_grouping_id = c.contractee_grouping_id)
  • Buffers: shared hit=85
18. 0.400 0.400 ↑ 6.0 77 1

CTE Scan on groupings_list (cost=350.94..360.22 rows=464 width=52) (actual time=0.008..0.400 rows=77 loops=1)

  • Output: groupings_list.original_grouping_id, NULL::uuid, groupings_list.grouping_id, NULL::integer
  • Buffers: shared hit=76
19.          

CTE groupings_list

20. 0.052 0.351 ↑ 6.0 77 1

Recursive Union (cost=0.00..350.94 rows=464 width=52) (actual time=0.007..0.351 rows=77 loops=1)

  • Buffers: shared hit=76
21. 0.041 0.041 ↑ 1.0 34 1

Seq Scan on client_kronos.grouping_company pg (cost=0.00..19.34 rows=34 width=52) (actual time=0.006..0.041 rows=34 loops=1)

  • Output: pg.grouping_id, pg.parent_grouping_id, pg.grouping_id, 0
  • Buffers: shared hit=19
22. 0.072 0.258 ↑ 3.1 14 3

Hash Join (cost=11.05..32.23 rows=43 width=52) (actual time=0.044..0.086 rows=14 loops=3)

  • Output: gl.original_grouping_id, cg.parent_grouping_id, cg.grouping_id, (gl.level + 1)
  • Hash Cond: (cg.parent_grouping_id = gl.grouping_id)
  • Buffers: shared hit=57
23. 0.141 0.141 ↑ 1.0 29 3

Seq Scan on client_kronos.grouping_company cg (cost=0.00..19.34 rows=29 width=32) (actual time=0.006..0.047 rows=29 loops=3)

  • Output: cg.grouping_id, cg.client_id, cg.grouping_description, cg.grouping_cd, cg.grouping_type, cg.parent_grouping_id, cg.active_ind, cg.company_type_id, cg.grouping_company_type
  • Filter: cg.active_ind
  • Rows Removed by Filter: 5
  • Buffers: shared hit=57
24. 0.027 0.045 ↑ 13.1 26 3

Hash (cost=6.80..6.80 rows=340 width=36) (actual time=0.015..0.015 rows=26 loops=3)

  • Output: gl.original_grouping_id, gl.level, gl.grouping_id
  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
25. 0.018 0.018 ↑ 13.1 26 3

WorkTable Scan on groupings_list gl (cost=0.00..6.80 rows=340 width=36) (actual time=0.002..0.006 rows=26 loops=3)

  • Output: gl.original_grouping_id, gl.level, gl.grouping_id
26. 0.001 0.016 ↑ 1.0 1 1

Hash (cost=6.91..6.91 rows=1 width=48) (actual time=0.016..0.016 rows=1 loops=1)

  • Output: c.contractee_grouping_id, c.contractee_company_id, cav_1.contract_amend_version_id
  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=9
27. 0.002 0.015 ↑ 1.0 1 1

Nested Loop (cost=0.84..6.91 rows=1 width=48) (actual time=0.014..0.015 rows=1 loops=1)

  • Output: c.contractee_grouping_id, c.contractee_company_id, cav_1.contract_amend_version_id
  • Inner Unique: true
  • Buffers: shared hit=9
28. 0.001 0.006 ↑ 1.0 1 1

Nested Loop (cost=0.56..6.60 rows=1 width=32) (actual time=0.006..0.006 rows=1 loops=1)

  • Output: crv_1.contract_family_id, cav_1.contract_amend_version_id
  • Inner Unique: true
  • Buffers: shared hit=6
29. 0.003 0.003 ↑ 1.0 1 1

Index Scan using contract_amend_version_pkey on client_kronos.contract_amend_version cav_1 (cost=0.28..3.30 rows=1 width=32) (actual time=0.002..0.003 rows=1 loops=1)

  • Output: cav_1.contract_amend_version_id, cav_1.contract_renew_version_id, cav_1.contract_state, cav_1.contract_amend_version_parent_id, cav_1.contract_name, cav_1.contact_name, cav_1.contact_email, cav_1.contact_phone, cav_1.create_timestamp, cav_1.amend_version
  • Index Cond: (cav_1.contract_amend_version_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid)
  • Buffers: shared hit=3
30. 0.002 0.002 ↑ 1.0 1 1

Index Scan using contract_version_pkey on client_kronos.contract_renew_version crv_1 (cost=0.28..3.30 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=1)

  • Output: crv_1.contract_renew_version_id, crv_1.contract_family_id, crv_1.date_range, crv_1.create_timestamp, crv_1.dead, crv_1.renew_version
  • Index Cond: (crv_1.contract_renew_version_id = cav_1.contract_renew_version_id)
  • Buffers: shared hit=3
31. 0.007 0.007 ↑ 1.0 1 1

Index Scan using contract_family_pkey on client_kronos.contract_family c (cost=0.28..0.31 rows=1 width=48) (actual time=0.007..0.007 rows=1 loops=1)

  • Output: c.contract_family_id, c.client_id, c.contractee_company_id, c.contractee_grouping_id, c.creator_id, c.contract_sequence, c.cost_basis_type, c.contract_type, c.contract_title, c.contract_template_id, c.payment_calendar_id, c.catch_all, c.accrual_quantity_source, c.import_contract_number, c.accrual_lumpsum_spread
  • Index Cond: (c.contract_family_id = crv_1.contract_family_id)
  • Buffers: shared hit=3
32. 21.185 21.185 ↑ 2.3 538 19

Index Only Scan using company_grouping_pkey on client_kronos.company_grouping cg_1 (cost=0.41..277.08 rows=1,251 width=32) (actual time=0.154..1.115 rows=538 loops=19)

  • Output: cg_1.company_id, cg_1.grouping_id
  • Index Cond: (cg_1.grouping_id = groupings_list.grouping_id)
  • Heap Fetches: 0
  • Buffers: shared hit=7,886
33. 20.448 20.448 ↑ 1.0 1 10,224

Index Only Scan using company_agg_pkey on client_kronos.company_agg cagg (cost=0.41..0.88 rows=1 width=32) (actual time=0.001..0.002 rows=1 loops=10,224)

  • Output: cagg.company_id, cagg.agg_company_id
  • Index Cond: (cagg.company_id = COALESCE(c.contractee_company_id, cg_1.company_id))
  • Heap Fetches: 0
  • Buffers: shared hit=31,095
34. 20.610 20.610 ↑ 1.0 1 10,305

Index Scan using company_pkey on client_kronos.company cmp (cost=0.29..0.34 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=10,305)

  • Output: cmp.company_id, cmp.client_id, cmp.company_name, cmp.company_number, cmp.company_type_id, cmp.active_ind, cmp.address_1, cmp.address_2, cmp.address_3, cmp.address_4, cmp.city, cmp.region, cmp.postal_code, cmp.country, cmp.company_agg_id, cmp.deduction_interval, cmp.alt_address_active, cmp.alt_address_1, cmp.alt_address_2, cmp.alt_address_3, cmp.alt_address_4, cmp.alt_city, cmp.alt_region, cmp.alt_postal_code, cmp.alt_country, cmp.atlas_company_id, cmp.email, cmp.tax_type_id, cmp.redistributor_ind, cmp.operator_request, cmp.early_payment_discount, cmp.vip, cmp.deduction_contact_email, cmp.is_unipro, cmp.is_golbon, cmp.is_ima, cmp.cross_ship_company_id, cmp.tpo_ind, cmp.auto_submit_eclaim, cmp.auto_approve_eclaim
  • Index Cond: (cmp.company_id = cagg.agg_company_id)
  • Buffers: shared hit=30,954
35. 0.002 0.010 ↑ 1.0 2 1

Hash (cost=1.02..1.02 rows=2 width=20) (actual time=0.010..0.010 rows=2 loops=1)

  • Output: ct.internal_company_type, ct.company_type_id
  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=1
36. 0.008 0.008 ↑ 1.0 2 1

Seq Scan on client_kronos.company_type ct (cost=0.00..1.02 rows=2 width=20) (actual time=0.007..0.008 rows=2 loops=1)

  • Output: ct.internal_company_type, ct.company_type_id
  • Buffers: shared hit=1
37. 0.005 65,520.582 ↓ 0.0 0 1

Sort (cost=4,513.19..4,513.20 rows=1 width=122) (actual time=65,520.582..65,520.582 rows=0 loops=1)

  • Output: param.contract_item_id, fi.quantity, tuomc.rate, suomc.rate, fi.date_range, param.date_range
  • Sort Key: param.contract_item_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=70,188 read=62, temp read=598,181 written=1,096,097
  • I/O Timings: read=0.746
38. 0.001 65,520.577 ↓ 0.0 0 1

Nested Loop (cost=4,488.85..4,513.18 rows=1 width=122) (actual time=65,520.577..65,520.577 rows=0 loops=1)

  • Output: param.contract_item_id, fi.quantity, tuomc.rate, suomc.rate, fi.date_range, param.date_range
  • Inner Unique: true
  • Join Filter: ((fi.product_id = suomc.product_id) AND (fi.uom_type_id = suomc.uom_type_id))
  • Buffers: shared hit=70,188 read=62, temp read=598,181 written=1,096,097
  • I/O Timings: read=0.746
39. 0.001 65,520.576 ↓ 0.0 0 1

Nested Loop (cost=4,488.57..4,512.80 rows=1 width=197) (actual time=65,520.576..65,520.576 rows=0 loops=1)

  • Output: param.contract_item_id, param.date_range, param.product_id, fi.quantity, fi.date_range, fi.product_id, fi.uom_type_id, pro.product_id, tuomc.rate, tuomc.product_id
  • Inner Unique: true
  • Join Filter: (fi.product_id = pro.product_id)
  • Buffers: shared hit=70,188 read=62, temp read=598,181 written=1,096,097
  • I/O Timings: read=0.746
40. 0.008 65,520.575 ↓ 0.0 0 1

Merge Join (cost=4,488.29..4,512.49 rows=1 width=181) (actual time=65,520.574..65,520.575 rows=0 loops=1)

  • Output: param.contract_item_id, param.date_range, param.product_id, fi.quantity, fi.date_range, fi.product_id, fi.uom_type_id, tuomc.rate, tuomc.product_id
  • Merge Cond: ((param.product_id = fi.product_id) AND (param.company_id = fi.company_id))
  • Join Filter: (fi.date_range && param.date_range)
  • Buffers: shared hit=70,188 read=62, temp read=598,181 written=1,096,097
  • I/O Timings: read=0.746
41. 43,841.363 65,520.526 ↑ 2,650.0 1 1

Sort (cost=4,449.63..4,456.26 rows=2,650 width=101) (actual time=65,520.526..65,520.526 rows=1 loops=1)

  • Output: param.contract_item_id, param.date_range, param.company_id, param.product_id, tuomc.rate, tuomc.product_id
  • Sort Key: param.product_id, param.company_id
  • Sort Method: external merge Disk: 2,048,224kB
  • Buffers: shared hit=70,188 read=62, temp read=598,181 written=1,096,097
  • I/O Timings: read=0.746
42. 6,936.164 21,679.163 ↓ 8,493.5 22,507,830 1

Hash Join (cost=253.20..4,298.96 rows=2,650 width=101) (actual time=74.239..21,679.163 rows=22,507,830 loops=1)

  • Output: param.contract_item_id, param.date_range, param.company_id, param.product_id, tuomc.rate, tuomc.product_id
  • Inner Unique: true
  • Hash Cond: ((param.product_id = tuomc.product_id) AND (param.uom_type_id = tuomc.uom_type_id))
  • Buffers: shared hit=70,188 read=62, temp written=241,783
  • I/O Timings: read=0.746
43. 14,739.644 14,739.644 ↓ 140.5 22,507,830 1

CTE Scan on param (cost=0.00..3,204.56 rows=160,228 width=96) (actual time=70.859..14,739.644 rows=22,507,830 loops=1)

  • Output: param.product_id, param.company_id, param.date_range, param.contract_item_id, param.uom_type_id
  • Buffers: shared hit=70,183, temp written=241,783
44. 1.375 3.355 ↓ 1.1 7,931 1

Hash (cost=141.48..141.48 rows=7,448 width=37) (actual time=3.355..3.355 rows=7,931 loops=1)

  • Output: tuomc.rate, tuomc.product_id, tuomc.uom_type_id
  • Buckets: 8,192 Batches: 1 Memory Usage: 600kB
  • Buffers: shared hit=5 read=62
  • I/O Timings: read=0.746
45. 1.980 1.980 ↓ 1.1 7,931 1

Seq Scan on client_kronos.product_uom_conversion tuomc (cost=0.00..141.48 rows=7,448 width=37) (actual time=0.232..1.980 rows=7,931 loops=1)

  • Output: tuomc.rate, tuomc.product_id, tuomc.uom_type_id
  • Buffers: shared hit=5 read=62
  • I/O Timings: read=0.746
46. 0.029 0.041 ↓ 0.0 0 1

Sort (cost=38.66..39.96 rows=520 width=112) (actual time=0.041..0.041 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.company_id, fi.product_id, fi.uom_type_id
  • Sort Key: fi.product_id, fi.company_id
  • Sort Method: quicksort Memory: 25kB
47. 0.012 0.012 ↓ 0.0 0 1

Seq Scan on client_kronos.forecast_objective fi (cost=0.00..15.20 rows=520 width=112) (actual time=0.012..0.012 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.company_id, fi.product_id, fi.uom_type_id
48. 0.000 0.000 ↓ 0.0 0

Index Only Scan using product_pkey on client_kronos.product pro (cost=0.28..0.30 rows=1 width=16) (never executed)

  • Output: pro.product_id
  • Index Cond: (pro.product_id = param.product_id)
  • Heap Fetches: 0
49. 0.000 0.000 ↓ 0.0 0

Index Scan using product_uom_conversion_pkey on client_kronos.product_uom_conversion suomc (cost=0.28..0.34 rows=3 width=37) (never executed)

  • Output: suomc.product_id, suomc.uom_type_id, suomc.rate
  • Index Cond: (suomc.product_id = param.product_id)
Planning time : 5.439 ms
Execution time : 66,152.739 ms