explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 8TAL

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 120,098.318 ↑ 4.0 1 1

Nested Loop Left Join (cost=13,485.16..13,491.27 rows=4 width=80) (actual time=120,098.312..120,098.318 rows=1 loops=1)

  • Output: ci.contract_item_id, COALESCE(base.quantity, '0'::numeric), COALESCE(obj.quantity, '0'::numeric)
  • Join Filter: (obj.contract_item_id = ci.contract_item_id)
  • Buffers: shared hit=70,316, temp read=1,438,147 written=1,950,412
2.          

CTE param

3. 3,061.526 4,705.947 ↓ 139.6 22,507,830 1

Nested Loop (cost=935.94..4,401.76 rows=161,205 width=78) (actual time=71.397..4,705.947 rows=22,507,830 loops=1)

  • Output: contract_product_materialized.contract_item_id, crv.date_range, cmp.company_id, contract_product_materialized.product_id, contract_product_materialized.uom_type_id
  • Buffers: shared hit=70,178
4. 4.625 4.873 ↓ 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.256..4.873 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.248 0.248 ↓ 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.248..0.248 rows=2,397 loops=1)

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

Materialize (cost=888.81..900.21 rows=165 width=46) (actual time=0.030..0.684 rows=9,390 loops=2,397)

  • Output: cav.contract_amend_version_id, crv.date_range, cmp.company_id
  • Buffers: shared hit=70,027
7. 1.209 75.085 ↓ 56.9 9,390 1

Nested Loop (cost=888.81..899.38 rows=165 width=46) (actual time=71.136..75.085 rows=9,390 loops=1)

  • Output: cav.contract_amend_version_id, crv.date_range, cmp.company_id
  • Buffers: shared hit=70,027
8. 0.003 0.025 ↑ 1.0 1 1

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

  • Output: cav.contract_amend_version_id, crv.date_range
  • Inner Unique: true
  • Buffers: shared hit=6
9. 0.016 0.016 ↑ 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.016 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.006 0.006 ↑ 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.006..0.006 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. 2.004 73.851 ↓ 56.9 9,390 1

Unique (cost=888.24..889.48 rows=165 width=36) (actual time=71.117..73.851 rows=9,390 loops=1)

  • Output: cav_1.contract_amend_version_id, cmp.company_id, ct.internal_company_type
  • Buffers: shared hit=70,021
12. 4.770 71.847 ↓ 62.5 10,305 1

Sort (cost=888.24..888.66 rows=165 width=36) (actual time=71.116..71.847 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,021
13. 3.328 67.077 ↓ 62.5 10,305 1

Hash Join (cost=360.03..882.17 rows=165 width=36) (actual time=0.090..67.077 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. 9.982 63.741 ↓ 62.5 10,305 1

Nested Loop (cost=358.98..879.78 rows=165 width=48) (actual time=0.076..63.741 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 43.454 ↓ 58.2 10,305 1

Nested Loop (cost=358.70..819.15 rows=177 width=32) (actual time=0.069..43.454 rows=10,305 loops=1)

  • Output: cav_1.contract_amend_version_id, cagg.agg_company_id
  • Buffers: shared hit=39,066
16. 1.419 23.502 ↓ 58.1 10,224 1

Nested Loop Left Join (cost=358.29..663.93 rows=176 width=48) (actual time=0.057..23.502 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.031 0.423 ↓ 19.0 19 1

Hash Right Join (cost=357.87..373.54 rows=1 width=48) (actual time=0.043..0.423 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.378 0.378 ↑ 6.0 77 1

CTE Scan on groupings_list (cost=350.94..360.22 rows=464 width=52) (actual time=0.008..0.378 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.061 0.327 ↑ 6.0 77 1

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

  • Buffers: shared hit=76
21. 0.038 0.038 ↑ 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.038 rows=34 loops=1)

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

Hash Join (cost=11.05..32.23 rows=43 width=52) (actual time=0.042..0.076 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.111 0.111 ↑ 1.0 29 3

Seq Scan on client_kronos.grouping_company cg (cost=0.00..19.34 rows=29 width=32) (actual time=0.005..0.037 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.015 0.033 ↑ 13.1 26 3

Hash (cost=6.80..6.80 rows=340 width=36) (actual time=0.011..0.011 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.001..0.006 rows=26 loops=3)

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

Hash (cost=6.91..6.91 rows=1 width=48) (actual time=0.014..0.014 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.001 0.013 ↑ 1.0 1 1

Nested Loop (cost=0.84..6.91 rows=1 width=48) (actual time=0.012..0.013 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.005..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.006 0.006 ↑ 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.006..0.006 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.660 21.660 ↑ 2.3 538 19

Index Only Scan using company_grouping_pkey on client_kronos.company_grouping cg_1 (cost=0.41..277.84 rows=1,255 width=32) (actual time=0.146..1.140 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.87 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. 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
35. 0.002 0.008 ↑ 1.0 2 1

Hash (cost=1.02..1.02 rows=2 width=20) (actual time=0.008..0.008 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.006 0.006 ↑ 1.0 2 1

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

  • Output: ct.internal_company_type, ct.company_type_id
  • Buffers: shared hit=1
37.          

CTE obj

38. 0.003 59,938.438 ↓ 0.0 0 1

GroupAggregate (cost=4,540.67..4,540.73 rows=1 width=48) (actual time=59,938.437..59,938.438 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=67, temp read=839,966 written=854,315
39. 0.004 59,938.435 ↓ 0.0 0 1

Sort (cost=4,540.67..4,540.67 rows=1 width=122) (actual time=59,938.435..59,938.435 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=67, temp read=839,966 written=854,315
40. 0.001 59,938.431 ↓ 0.0 0 1

Nested Loop (cost=4,516.20..4,540.66 rows=1 width=122) (actual time=59,938.431..59,938.431 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=67, temp read=839,966 written=854,315
41. 0.002 59,938.430 ↓ 0.0 0 1

Nested Loop (cost=4,515.92..4,540.28 rows=1 width=197) (actual time=59,938.430..59,938.430 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=67, temp read=839,966 written=854,315
42. 0.008 59,938.428 ↓ 0.0 0 1

Merge Join (cost=4,515.64..4,539.97 rows=1 width=181) (actual time=59,938.428..59,938.428 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=67, temp read=839,966 written=854,315
43. 43,553.789 59,938.386 ↑ 2,666.0 1 1

Sort (cost=4,476.98..4,483.64 rows=2,666 width=101) (actual time=59,938.386..59,938.386 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=67, temp read=839,966 written=854,315
44. 6,575.435 16,384.597 ↓ 8,442.5 22,507,830 1

Hash Join (cost=254.85..4,325.28 rows=2,666 width=101) (actual time=2.548..16,384.597 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=67, temp read=241,785 written=1
45. 9,806.906 9,806.906 ↓ 139.6 22,507,830 1

CTE Scan on param (cost=0.00..3,224.10 rows=161,205 width=96) (actual time=0.267..9,806.906 rows=22,507,830 loops=1)

  • Output: param.contract_item_id, param.date_range, param.company_id, param.product_id, param.uom_type_id
  • Buffers: temp read=241,785 written=1
46. 1.233 2.256 ↓ 1.1 7,931 1

Hash (cost=142.14..142.14 rows=7,514 width=37) (actual time=2.256..2.256 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=67
47. 1.023 1.023 ↓ 1.1 7,931 1

Seq Scan on client_kronos.product_uom_conversion tuomc (cost=0.00..142.14 rows=7,514 width=37) (actual time=0.015..1.023 rows=7,931 loops=1)

  • Output: tuomc.rate, tuomc.product_id, tuomc.uom_type_id
  • Buffers: shared hit=67
48. 0.024 0.034 ↓ 0.0 0 1

Sort (cost=38.66..39.96 rows=520 width=112) (actual time=0.034..0.034 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
49. 0.010 0.010 ↓ 0.0 0 1

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

  • Output: fi.quantity, fi.date_range, fi.company_id, fi.product_id, fi.uom_type_id
50. 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
51. 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)
52.          

CTE base

53. 0.001 60,159.846 ↓ 0.0 0 1

GroupAggregate (cost=4,540.67..4,540.73 rows=1 width=48) (actual time=60,159.846..60,159.846 rows=0 loops=1)

  • Output: param_1.contract_item_id, sum((((fi_1.quantity * (tuomc_1.rate / suomc_1.rate)) / ((upper(fi_1.date_range) - lower(fi_1.date_range)))::numeric) * ((upper((fi_1.date_range * param_1.date_range)) - lower((fi_1.date_range * param_1.date_range))))::numeric))
  • Group Key: param_1.contract_item_id
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
54. 0.006 60,159.845 ↓ 0.0 0 1

Sort (cost=4,540.67..4,540.67 rows=1 width=122) (actual time=60,159.845..60,159.845 rows=0 loops=1)

  • Output: param_1.contract_item_id, fi_1.quantity, tuomc_1.rate, suomc_1.rate, fi_1.date_range, param_1.date_range
  • Sort Key: param_1.contract_item_id
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
55. 0.000 60,159.839 ↓ 0.0 0 1

Nested Loop (cost=4,516.20..4,540.66 rows=1 width=122) (actual time=60,159.839..60,159.839 rows=0 loops=1)

  • Output: param_1.contract_item_id, fi_1.quantity, tuomc_1.rate, suomc_1.rate, fi_1.date_range, param_1.date_range
  • Inner Unique: true
  • Join Filter: ((fi_1.product_id = suomc_1.product_id) AND (fi_1.uom_type_id = suomc_1.uom_type_id))
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
56. 0.001 60,159.839 ↓ 0.0 0 1

Nested Loop (cost=4,515.92..4,540.28 rows=1 width=197) (actual time=60,159.839..60,159.839 rows=0 loops=1)

  • Output: param_1.contract_item_id, param_1.date_range, param_1.product_id, fi_1.quantity, fi_1.date_range, fi_1.product_id, fi_1.uom_type_id, pro_1.product_id, tuomc_1.rate, tuomc_1.product_id
  • Inner Unique: true
  • Join Filter: (fi_1.product_id = pro_1.product_id)
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
57. 0.006 60,159.838 ↓ 0.0 0 1

Merge Join (cost=4,515.64..4,539.97 rows=1 width=181) (actual time=60,159.838..60,159.838 rows=0 loops=1)

  • Output: param_1.contract_item_id, param_1.date_range, param_1.product_id, fi_1.quantity, fi_1.date_range, fi_1.product_id, fi_1.uom_type_id, tuomc_1.rate, tuomc_1.product_id
  • Merge Cond: ((param_1.product_id = fi_1.product_id) AND (param_1.company_id = fi_1.company_id))
  • Join Filter: (fi_1.date_range && param_1.date_range)
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
58. 39,539.637 60,159.804 ↑ 2,666.0 1 1

Sort (cost=4,476.98..4,483.64 rows=2,666 width=101) (actual time=60,159.804..60,159.804 rows=1 loops=1)

  • Output: param_1.contract_item_id, param_1.date_range, param_1.company_id, param_1.product_id, tuomc_1.rate, tuomc_1.product_id
  • Sort Key: param_1.product_id, param_1.company_id
  • Sort Method: external merge Disk: 2,048,224kB
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
59. 6,728.626 20,620.167 ↓ 8,442.5 22,507,830 1

Hash Join (cost=254.85..4,325.28 rows=2,666 width=101) (actual time=74.091..20,620.167 rows=22,507,830 loops=1)

  • Output: param_1.contract_item_id, param_1.date_range, param_1.company_id, param_1.product_id, tuomc_1.rate, tuomc_1.product_id
  • Inner Unique: true
  • Hash Cond: ((param_1.product_id = tuomc_1.product_id) AND (param_1.uom_type_id = tuomc_1.uom_type_id))
  • Buffers: shared hit=70,245, temp written=241,783
60. 13,888.870 13,888.870 ↓ 139.6 22,507,830 1

CTE Scan on param param_1 (cost=0.00..3,224.10 rows=161,205 width=96) (actual time=71.399..13,888.870 rows=22,507,830 loops=1)

  • Output: param_1.contract_item_id, param_1.date_range, param_1.company_id, param_1.product_id, param_1.uom_type_id
  • Buffers: shared hit=70,178, temp written=241,783
61. 1.587 2.671 ↓ 1.1 7,931 1

Hash (cost=142.14..142.14 rows=7,514 width=37) (actual time=2.671..2.671 rows=7,931 loops=1)

  • Output: tuomc_1.rate, tuomc_1.product_id, tuomc_1.uom_type_id
  • Buckets: 8,192 Batches: 1 Memory Usage: 600kB
  • Buffers: shared hit=67
62. 1.084 1.084 ↓ 1.1 7,931 1

Seq Scan on client_kronos.product_uom_conversion tuomc_1 (cost=0.00..142.14 rows=7,514 width=37) (actual time=0.008..1.084 rows=7,931 loops=1)

  • Output: tuomc_1.rate, tuomc_1.product_id, tuomc_1.uom_type_id
  • Buffers: shared hit=67
63. 0.019 0.028 ↓ 0.0 0 1

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

  • Output: fi_1.quantity, fi_1.date_range, fi_1.company_id, fi_1.product_id, fi_1.uom_type_id
  • Sort Key: fi_1.product_id, fi_1.company_id
  • Sort Method: quicksort Memory: 25kB
64. 0.009 0.009 ↓ 0.0 0 1

Seq Scan on client_kronos.forecast_base fi_1 (cost=0.00..15.20 rows=520 width=112) (actual time=0.009..0.009 rows=0 loops=1)

  • Output: fi_1.quantity, fi_1.date_range, fi_1.company_id, fi_1.product_id, fi_1.uom_type_id
65. 0.000 0.000 ↓ 0.0 0

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

  • Output: pro_1.product_id
  • Index Cond: (pro_1.product_id = param_1.product_id)
  • Heap Fetches: 0
66. 0.000 0.000 ↓ 0.0 0

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

  • Output: suomc_1.product_id, suomc_1.uom_type_id, suomc_1.rate
  • Index Cond: (suomc_1.product_id = param_1.product_id)
67. 0.004 60,159.871 ↑ 4.0 1 1

Nested Loop Left Join (cost=1.94..7.96 rows=4 width=48) (actual time=60,159.867..60,159.871 rows=1 loops=1)

  • Output: ci.contract_item_id, base.quantity
  • Join Filter: (base.contract_item_id = ci.contract_item_id)
  • Buffers: shared hit=70,249, temp read=598,181 written=1,096,097
68. 0.007 0.019 ↑ 4.0 1 1

Bitmap Heap Scan on client_kronos.contract_item ci (cost=1.94..7.86 rows=4 width=16) (actual time=0.015..0.019 rows=1 loops=1)

  • Output: ci.contract_item_id, ci.contract_id, ci.product_id, ci.grouping_id, ci.estimated_quantity, ci.uom_type_id, ci.rebate_deviated_value, ci.rebate_deviated_type, ci.inactive_override, ci.rebate_direct_value, ci.rebate_direct_type, ci.rebate_direct_decimal_model, ci.rebate_deviated_decimal_model, ci.won, ci.rebate_growth_type, ci.rebate_growth_decimal_model, ci.lift_quantity
  • Recheck Cond: (ci.contract_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid)
  • Heap Blocks: exact=1
  • Buffers: shared hit=4
69. 0.012 0.012 ↑ 4.0 1 1

Bitmap Index Scan on contract_item_product_unique (cost=0.00..1.94 rows=4 width=0) (actual time=0.012..0.012 rows=1 loops=1)

  • Index Cond: (ci.contract_id = '68a454a3-15e7-11ea-be40-e981416a043d'::uuid)
  • Buffers: shared hit=3
70. 60,159.848 60,159.848 ↓ 0.0 0 1

CTE Scan on base (cost=0.00..0.02 rows=1 width=48) (actual time=60,159.848..60,159.848 rows=0 loops=1)

  • Output: base.contract_item_id, base.quantity
  • Buffers: shared hit=70,245, temp read=598,181 written=1,096,097
71. 59,938.439 59,938.439 ↓ 0.0 0 1

CTE Scan on obj (cost=0.00..0.02 rows=1 width=48) (actual time=59,938.439..59,938.439 rows=0 loops=1)

  • Output: obj.contract_item_id, obj.quantity
  • Buffers: shared hit=67, temp read=839,966 written=854,315
Planning time : 5.731 ms
Execution time : 120,695.522 ms