explain.depesz.com

PostgreSQL's explain analyze made readable

Result: XGK7

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 66.181 ↓ 0.0 0 1

GroupAggregate (cost=903.10..903.16 rows=1 width=48) (actual time=66.181..66.181 rows=0 loops=1)

  • Output: contract_product_materialized.contract_item_id, sum((((fi.quantity * (tuomc.rate / suomc.rate)) / ((upper(fi.date_range) - lower(fi.date_range)))::numeric) * ((upper((fi.date_range * crv.date_range)) - lower((fi.date_range * crv.date_range))))::numeric))
  • Group Key: contract_product_materialized.contract_item_id
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
2. 0.005 66.179 ↓ 0.0 0 1

Sort (cost=903.10..903.11 rows=1 width=104) (actual time=66.179..66.179 rows=0 loops=1)

  • Output: contract_product_materialized.contract_item_id, fi.quantity, tuomc.rate, suomc.rate, fi.date_range, crv.date_range
  • Sort Key: contract_product_materialized.contract_item_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
3. 0.000 66.174 ↓ 0.0 0 1

Nested Loop (cost=895.71..903.09 rows=1 width=104) (actual time=66.174..66.174 rows=0 loops=1)

  • Output: contract_product_materialized.contract_item_id, fi.quantity, tuomc.rate, suomc.rate, fi.date_range, crv.date_range
  • Inner Unique: true
  • Join Filter: ((fi.product_id = tuomc.product_id) AND (contract_product_materialized.uom_type_id = tuomc.uom_type_id))
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
4. 0.001 66.174 ↓ 0.0 0 1

Nested Loop (cost=895.43..902.69 rows=1 width=179) (actual time=66.174..66.174 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.product_id, crv.date_range, contract_product_materialized.contract_item_id, contract_product_materialized.product_id, contract_product_materialized.uom_type_id, pro.product_id, suomc.rate, suomc.product_id
  • Inner Unique: true
  • Join Filter: (fi.product_id = contract_product_materialized.product_id)
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
5. 0.000 66.173 ↓ 0.0 0 1

Nested Loop (cost=894.87..899.20 rows=1 width=147) (actual time=66.173..66.173 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.product_id, crv.date_range, cav.contract_amend_version_id, pro.product_id, suomc.rate, suomc.product_id
  • Inner Unique: true
  • Join Filter: ((fi.product_id = suomc.product_id) AND (fi.uom_type_id = suomc.uom_type_id))
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
6. 0.001 66.173 ↓ 0.0 0 1

Nested Loop (cost=894.59..898.29 rows=2 width=142) (actual time=66.172..66.173 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.product_id, fi.uom_type_id, crv.date_range, cav.contract_amend_version_id, pro.product_id
  • Inner Unique: true
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
7. 0.004 66.172 ↓ 0.0 0 1

Merge Join (cost=894.31..897.63 rows=2 width=126) (actual time=66.172..66.172 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.product_id, fi.uom_type_id, crv.date_range, cav.contract_amend_version_id
  • Merge Cond: (cmp.company_id = fi.company_id)
  • Buffers: shared hit=70,056 read=1
  • I/O Timings: read=0.349
8. 0.001 65.265 ↑ 164.0 1 1

Unique (cost=887.40..888.63 rows=164 width=36) (actual time=65.265..65.265 rows=1 loops=1)

  • Output: cav_1.contract_amend_version_id, cmp.company_id, ct.internal_company_type
  • Buffers: shared hit=70,026
9. 3.969 65.264 ↑ 164.0 1 1

Sort (cost=887.40..887.81 rows=164 width=36) (actual time=65.264..65.264 rows=1 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
10. 2.982 61.295 ↓ 62.8 10,305 1

Hash Join (cost=360.03..881.37 rows=164 width=36) (actual time=0.164..61.295 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
11. 8.469 58.298 ↓ 62.8 10,305 1

Nested Loop (cost=358.98..878.98 rows=164 width=48) (actual time=0.143..58.298 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
12. 8.490 39.524 ↓ 58.6 10,305 1

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

  • Output: cav_1.contract_amend_version_id, cagg.agg_company_id
  • Buffers: shared hit=39,066
13. 1.354 20.810 ↓ 58.4 10,224 1

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

  • Output: c.contractee_company_id, cav_1.contract_amend_version_id, cg.company_id
  • Buffers: shared hit=7,971
14. 0.033 0.418 ↓ 19.0 19 1

Hash Right Join (cost=357.87..373.54 rows=1 width=48) (actual time=0.057..0.418 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
15. 0.357 0.357 ↑ 6.0 77 1

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

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

CTE groupings_list

17. 0.070 0.312 ↑ 6.0 77 1

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

  • Buffers: shared hit=76
18. 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.005..0.041 rows=34 loops=1)

  • Output: pg.grouping_id, pg.parent_grouping_id, pg.grouping_id, 0
  • Buffers: shared hit=19
19. 0.069 0.201 ↑ 3.1 14 3

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

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

Seq Scan on client_kronos.grouping_company cg_1 (cost=0.00..19.34 rows=29 width=32) (actual time=0.005..0.034 rows=29 loops=3)

  • Output: cg_1.grouping_id, cg_1.client_id, cg_1.grouping_description, cg_1.grouping_cd, cg_1.grouping_type, cg_1.parent_grouping_id, cg_1.active_ind, cg_1.company_type_id, cg_1.grouping_company_type
  • Filter: cg_1.active_ind
  • Rows Removed by Filter: 5
  • Buffers: shared hit=57
21. 0.015 0.030 ↑ 13.1 26 3

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

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

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

  • Output: gl.original_grouping_id, gl.level, gl.grouping_id
23. 0.001 0.028 ↑ 1.0 1 1

Hash (cost=6.91..6.91 rows=1 width=48) (actual time=0.028..0.028 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
24. 0.002 0.027 ↑ 1.0 1 1

Nested Loop (cost=0.84..6.91 rows=1 width=48) (actual time=0.026..0.027 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
25. 0.001 0.018 ↑ 1.0 1 1

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

  • Output: crv_1.contract_family_id, cav_1.contract_amend_version_id
  • Inner Unique: true
  • Buffers: shared hit=6
26. 0.009 0.009 ↑ 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.009..0.009 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
27. 0.008 0.008 ↑ 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.008..0.008 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
28. 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
29. 19.038 19.038 ↑ 2.3 538 19

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

  • Output: cg.company_id, cg.grouping_id
  • Index Cond: (cg.grouping_id = groupings_list.grouping_id)
  • Heap Fetches: 0
  • Buffers: shared hit=7,886
30. 10.224 10.224 ↑ 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.001 rows=1 loops=10,224)

  • Output: cagg.company_id, cagg.agg_company_id
  • Index Cond: (cagg.company_id = COALESCE(c.contractee_company_id, cg.company_id))
  • Heap Fetches: 0
  • Buffers: shared hit=31,095
31. 10.305 10.305 ↑ 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.001..0.001 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
32. 0.003 0.015 ↑ 1.0 2 1

Hash (cost=1.02..1.02 rows=2 width=20) (actual time=0.014..0.015 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
33. 0.012 0.012 ↑ 1.0 2 1

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

  • Output: ct.internal_company_type, ct.company_type_id
  • Buffers: shared hit=1
34. 0.008 0.903 ↓ 0.0 0 1

Sort (cost=6.91..6.92 rows=3 width=142) (actual time=0.903..0.903 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.company_id, fi.product_id, fi.uom_type_id, crv.date_range, cav.contract_amend_version_id
  • Sort Key: fi.company_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=30 read=1
  • I/O Timings: read=0.349
35. 0.003 0.895 ↓ 0.0 0 1

Nested Loop (cost=0.71..6.88 rows=3 width=142) (actual time=0.895..0.895 rows=0 loops=1)

  • Output: fi.quantity, fi.date_range, fi.company_id, fi.product_id, fi.uom_type_id, crv.date_range, cav.contract_amend_version_id
  • Buffers: shared hit=30 read=1
  • I/O Timings: read=0.349
36. 0.002 0.025 ↑ 1.0 1 1

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

  • Output: cav.contract_amend_version_id, crv.date_range
  • Inner Unique: true
  • Buffers: shared hit=6
37. 0.014 0.014 ↑ 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.012..0.014 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
38. 0.009 0.009 ↑ 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.009..0.009 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
39. 0.867 0.867 ↓ 0.0 0 1

Index Scan using forecast_objective_exclusion on client_kronos.forecast_objective fi (cost=0.14..0.23 rows=5 width=112) (actual time=0.867..0.867 rows=0 loops=1)

  • Output: fi.forecast_objective_id, fi.product_id, fi.company_id, fi.date_range, fi.uom_type_id, fi.quantity
  • Index Cond: (fi.date_range && crv.date_range)
  • Buffers: shared hit=24 read=1
  • I/O Timings: read=0.349
40. 0.000 0.000 ↓ 0.0 0

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

  • Output: pro.product_id
  • Index Cond: (pro.product_id = fi.product_id)
  • Heap Fetches: 0
41. 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.41 rows=3 width=37) (never executed)

  • Output: suomc.product_id, suomc.uom_type_id, suomc.rate
  • Index Cond: (suomc.product_id = pro.product_id)
42. 0.000 0.000 ↓ 0.0 0

Index Scan using contract_product_materialized_pkey on client_kronos.contract_product_materialized (cost=0.56..3.47 rows=1 width=64) (never executed)

  • 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
  • Index Cond: ((contract_product_materialized.contract_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid) AND (contract_product_materialized.product_id = suomc.product_id))
43. 0.000 0.000 ↓ 0.0 0

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

  • Output: tuomc.product_id, tuomc.uom_type_id, tuomc.rate
  • Index Cond: (tuomc.product_id = suomc.product_id)
Planning time : 19.167 ms
Execution time : 66.567 ms