explain.depesz.com

PostgreSQL's explain analyze made readable

Result: itAf

Settings
# exclusive inclusive rows x rows loops node
1. 0.171 3,146.188 ↓ 11.6 721 1

Unique (cost=311,517.19..311,517.81 rows=62 width=53) (actual time=3,145.965..3,146.188 rows=721 loops=1)

2. 0.264 3,146.017 ↓ 11.6 721 1

Sort (cost=311,517.19..311,517.34 rows=62 width=53) (actual time=3,145.965..3,146.017 rows=721 loops=1)

  • Sort Key: nc_contractor_info.proj_id, nc_contractor_info.internal_order_id, nc_contractor_info.main_contractor, nc_contractor_info.warranty_expiry DESC
  • Sort Method: quicksort Memory: 125kB
3. 0.150 3,145.753 ↓ 11.6 721 1

Subquery Scan on nc_contractor_info (cost=311,512.71..311,515.34 rows=62 width=53) (actual time=3,145.277..3,145.753 rows=721 loops=1)

4. 0.265 3,145.603 ↓ 11.6 721 1

Unique (cost=311,512.71..311,514.72 rows=62 width=249) (actual time=3,145.276..3,145.603 rows=721 loops=1)

5. 0.567 3,145.338 ↓ 11.6 721 1

Sort (cost=311,512.71..311,512.86 rows=62 width=249) (actual time=3,145.276..3,145.338 rows=721 loops=1)

  • Sort Key: v.proj_id, v.internal_order_id, v.main_contractor, v.po_id, v.po_item_id, v.doc_no, v.objective_id, v.objective_snap, v.budget_sub_category_high_rise_id, v.budget_sub_category_high_rise_name_snap, v.warranty_expiry, v.source
  • Sort Method: quicksort Memory: 126kB
6. 0.122 3,144.771 ↓ 11.6 721 1

Subquery Scan on v (cost=311,509.62..311,510.86 rows=62 width=249) (actual time=3,144.393..3,144.771 rows=721 loops=1)

7. 0.733 3,144.649 ↓ 11.6 721 1

HashAggregate (cost=311,509.62..311,510.24 rows=62 width=249) (actual time=3,144.393..3,144.649 rows=721 loops=1)

  • Group Key: nc_contractor_info_excl_migrate.source, nc_contractor_info_excl_migrate.proj_id, nc_contractor_info_excl_migrate.proj_type, nc_contractor_info_excl_migrate.internal_order_id, nc_contractor_info_excl_migrate.contractor_id, nc_contractor_info_excl_migrate.main_contractor, nc_contractor_info_excl_migrate.po_id, nc_contractor_info_excl_migrate.po_item_id, nc_contractor_info_excl_migrate.doc_no, nc_contractor_info_excl_migrate.objective_id, nc_contractor_info_excl_migrate.objective_snap, nc_contractor_info_excl_migrate.budget_sub_category_high_rise_id, nc_contractor_info_excl_migrate.budget_sub_category_high_rise_name_snap, nc_contractor_info_excl_migrate.warranty_expiry
8. 0.091 3,143.916 ↓ 11.6 721 1

Append (cost=3,167.09..311,507.45 rows=62 width=249) (actual time=590.976..3,143.916 rows=721 loops=1)

9. 0.205 591.229 ↓ 11.4 663 1

Unique (cost=3,167.09..3,168.98 rows=58 width=249) (actual time=590.975..591.229 rows=663 loops=1)

10. 0.317 591.024 ↓ 11.4 663 1

Sort (cost=3,167.09..3,167.24 rows=58 width=249) (actual time=590.975..591.024 rows=663 loops=1)

  • Sort Key: nc_contractor_info_excl_migrate.source, nc_contractor_info_excl_migrate.proj_id, nc_contractor_info_excl_migrate.internal_order_id, nc_contractor_info_excl_migrate.main_contractor, nc_contractor_info_excl_migrate.po_id, nc_contractor_info_excl_migrate.po_item_id, nc_contractor_info_excl_migrate.doc_no, nc_contractor_info_excl_migrate.objective_id, nc_contractor_info_excl_migrate.objective_snap, nc_contractor_info_excl_migrate.budget_sub_category_high_rise_id, nc_contractor_info_excl_migrate.budget_sub_category_high_rise_name_snap, nc_contractor_info_excl_migrate.warranty_expiry
  • Sort Method: quicksort Memory: 118kB
11. 0.160 590.707 ↓ 11.4 663 1

Subquery Scan on nc_contractor_info_excl_migrate (cost=3,162.93..3,165.40 rows=58 width=249) (actual time=590.256..590.707 rows=663 loops=1)

12. 0.235 590.547 ↓ 11.4 663 1

Unique (cost=3,162.93..3,164.82 rows=58 width=249) (actual time=590.254..590.547 rows=663 loops=1)

13. 0.516 590.312 ↓ 11.4 663 1

Sort (cost=3,162.93..3,163.08 rows=58 width=249) (actual time=590.254..590.312 rows=663 loops=1)

  • Sort Key: "*SELECT* 1".proj_id, (NULL::uuid), (false), (NULL::uuid), (NULL::uuid), (NULL::character varying(255)), (NULL::uuid), (NULL::character varying(500)), (NULL::uuid), ((NULL::character varying(501))::character varying(501)) COLLATE thai, (NULL::date), ('PROJ_CONTRACTOR'::text)
  • Sort Method: quicksort Memory: 118kB
14. 0.205 589.796 ↓ 11.4 663 1

Hash Join (cost=3,159.16..3,161.23 rows=58 width=249) (actual time=589.374..589.796 rows=663 loops=1)

  • Hash Cond: ("*SELECT* 1".proj_id = proj.id)
15. 0.731 589.531 ↓ 8.5 769 1

HashAggregate (cost=3,145.16..3,146.07 rows=91 width=245) (actual time=589.305..589.531 rows=769 loops=1)

  • Group Key: ('PROJ_CONTRACTOR'::text), "*SELECT* 1".proj_id, (NULL::uuid), "*SELECT* 1".contractor_id, (false), (NULL::uuid), (NULL::uuid), (NULL::character varying(255)), (NULL::uuid), (NULL::character varying(500)), (NULL::uuid), ((NULL::character varying(501))::character varying(501)), (NULL::date)
16. 0.112 588.800 ↓ 8.5 769 1

Append (cost=31.24..3,142.20 rows=91 width=245) (actual time=583.928..588.800 rows=769 loops=1)

17. 0.001 0.054 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1 (cost=31.24..31.27 rows=2 width=1,697) (actual time=0.054..0.054 rows=0 loops=1)

18. 0.002 0.053 ↓ 0.0 0 1

Unique (cost=31.24..31.25 rows=2 width=1,697) (actual time=0.053..0.053 rows=0 loops=1)

19. 0.005 0.051 ↓ 0.0 0 1

Sort (cost=31.24..31.24 rows=2 width=1,697) (actual time=0.051..0.051 rows=0 loops=1)

  • Sort Key: proj_1.id
  • Sort Method: quicksort Memory: 25kB
20. 0.003 0.046 ↓ 0.0 0 1

Nested Loop (cost=9.94..31.23 rows=2 width=1,697) (actual time=0.046..0.046 rows=0 loops=1)

21. 0.017 0.017 ↑ 1.0 1 1

Index Only Scan using contractor_pkey on contractor c (cost=0.29..8.30 rows=1 width=16) (actual time=0.017..0.017 rows=1 loops=1)

  • Index Cond: (id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
  • Heap Fetches: 1
22. 0.008 0.026 ↓ 0.0 0 1

Hash Join (cost=9.66..22.91 rows=2 width=32) (actual time=0.026..0.026 rows=0 loops=1)

  • Hash Cond: (proj_1.id = pc.proj_id)
23. 0.005 0.005 ↑ 98.0 1 1

Seq Scan on proj proj_1 (cost=0.00..12.98 rows=98 width=16) (actual time=0.005..0.005 rows=1 loops=1)

24. 0.001 0.013 ↓ 0.0 0 1

Hash (cost=9.63..9.63 rows=2 width=32) (actual time=0.013..0.013 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
25. 0.004 0.012 ↓ 0.0 0 1

Bitmap Heap Scan on proj_contractor pc (cost=4.29..9.63 rows=2 width=32) (actual time=0.012..0.012 rows=0 loops=1)

  • Recheck Cond: (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
26. 0.008 0.008 ↓ 0.0 0 1

Bitmap Index Scan on proj_contractor_uindex (cost=0.00..4.29 rows=2 width=0) (actual time=0.008..0.008 rows=0 loops=1)

  • Index Cond: (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
27. 0.001 1.676 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2 (cost=268.56..268.71 rows=4 width=784) (actual time=1.676..1.676 rows=0 loops=1)

28. 0.002 1.675 ↓ 0.0 0 1

Unique (cost=268.56..268.67 rows=4 width=1,268) (actual time=1.675..1.675 rows=0 loops=1)

29. 0.018 1.673 ↓ 0.0 0 1

Sort (cost=268.56..268.57 rows=4 width=1,268) (actual time=1.673..1.673 rows=0 loops=1)

  • Sort Key: ((po.po_type)::character varying(255)), po.proj_id, pi.internal_order_id, (CASE WHEN ((po.po_type = 'LOW_CONTRACT'::po_type) AND (po.contractor_id = io.main_contractor_id)) THEN true ELSE false END), po.id, (CASE WHEN (po.po_type = 'LOW_CONTRACT'::po_type) THEN pi.id ELSE NULL::uuid END), (COALESCE(po.contract_doc_no, po.po_no)), po.objective_id, po.objective_snap, (COALESCE((pi.allow_rebate_retention_bond_start_date - 1), pi.retention_end_date))
  • Sort Method: quicksort Memory: 25kB
30. 0.002 1.655 ↓ 0.0 0 1

Nested Loop Left Join (cost=4.60..268.52 rows=4 width=1,268) (actual time=1.655..1.655 rows=0 loops=1)

31. 0.004 1.653 ↓ 0.0 0 1

Nested Loop (cost=4.31..256.90 rows=4 width=228) (actual time=1.653..1.653 rows=0 loops=1)

32. 1.649 1.649 ↓ 0.0 0 1

Seq Scan on po (cost=0.00..237.74 rows=1 width=188) (actual time=1.649..1.649 rows=0 loops=1)

  • Filter: ((po_type = ANY ('{LOW_CONTRACT,LOW_PO_HOUSE}'::po_type[])) AND (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid) AND (po_status <> ALL ('{DRAFT,DRAFT_SEND_BACK,WAITING_FOR_AUTHORITY_APPROVAL,WAITING_FOR_APPROVAL,CANCELED,REJECTED,APPROVED,PRINTED,WAITING_FOR_RELEASE}'::po_status[])))
  • Rows Removed by Filter: 1095
33. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on po_item pi (cost=4.31..19.11 rows=4 width=56) (never executed)

  • Recheck Cond: (po_id = po.id)
34. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on po_item_po_id_ord_key (cost=0.00..4.31 rows=4 width=0) (never executed)

  • Index Cond: (po_id = po.id)
35. 0.000 0.000 ↓ 0.0 0

Index Scan using internal_order_pkey on internal_order io (cost=0.29..2.89 rows=1 width=32) (never executed)

  • Index Cond: (id = pi.internal_order_id)
36. 0.003 1.749 ↓ 0.0 0 1

Subquery Scan on *SELECT* 3 (cost=706.95..706.98 rows=1 width=784) (actual time=1.748..1.749 rows=0 loops=1)

37. 0.003 1.746 ↓ 0.0 0 1

Unique (cost=706.95..706.97 rows=1 width=1,268) (actual time=1.746..1.746 rows=0 loops=1)

38. 0.107 1.743 ↓ 0.0 0 1

Sort (cost=706.95..706.95 rows=1 width=1,268) (actual time=1.743..1.743 rows=0 loops=1)

  • Sort Key: ((po_1.po_type)::character varying(255)), po_1.proj_id, po_1.id, (COALESCE(po_1.contract_doc_no, po_1.po_no)), po_1.objective_id, po_1.objective_snap, po_1.budget_sub_cat_id, ((bschr.name)::character varying(500)) COLLATE thai, (COALESCE(((max(po_item.allow_rebate_retention_bond_start_date)) - 1), (max(po_item.retention_end_date))))
  • Sort Method: quicksort Memory: 25kB
39. 0.004 1.636 ↓ 0.0 0 1

Nested Loop Left Join (cost=680.26..706.94 rows=1 width=1,268) (actual time=1.636..1.636 rows=0 loops=1)

  • Join Filter: (po_1.budget_sub_cat_id = bschr.id)
40. 0.110 1.632 ↓ 0.0 0 1

Hash Right Join (cost=680.26..705.05 rows=1 width=212) (actual time=1.632..1.632 rows=0 loops=1)

  • Hash Cond: (po_item.po_id = po_1.id)
41. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=439.77..450.72 rows=1,095 width=24) (never executed)

  • Group Key: po_item.po_id
42. 0.000 0.000 ↓ 0.0 0

Seq Scan on po_item (cost=0.00..409.44 rows=4,044 width=24) (never executed)

43. 0.004 1.522 ↓ 0.0 0 1

Hash (cost=240.48..240.48 rows=1 width=204) (actual time=1.521..1.522 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
44. 1.518 1.518 ↓ 0.0 0 1

Seq Scan on po po_1 (cost=0.00..240.48 rows=1 width=204) (actual time=1.518..1.518 rows=0 loops=1)

  • Filter: ((contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid) AND (po_type = ANY ('{LOW_PO_UTILITY,LOW_CONTRACT_UTILITY,HIGH_PO_BUDGET_CTRL,HIGH_PO_OTHER}'::po_type[])) AND (po_status <> ALL ('{DRAFT,DRAFT_SEND_BACK,WAITING_FOR_AUTHORITY_APPROVAL,WAITING_FOR_APPROVAL,CANCELED,REJECTED,APPROVED,PRINTED,WAITING_FOR_RELEASE}'::po_status[])))
  • Rows Removed by Filter: 1095
45. 0.000 0.000 ↓ 0.0 0

Seq Scan on budget_sub_category_high_rise bschr (cost=0.00..1.39 rows=39 width=532) (never executed)

46. 0.004 1.020 ↓ 0.0 0 1

Subquery Scan on *SELECT* 4 (cost=257.63..257.79 rows=4 width=784) (actual time=1.020..1.020 rows=0 loops=1)

47. 0.001 1.016 ↓ 0.0 0 1

Unique (cost=257.63..257.75 rows=4 width=1,268) (actual time=1.016..1.016 rows=0 loops=1)

48. 0.054 1.015 ↓ 0.0 0 1

Sort (cost=257.63..257.64 rows=4 width=1,268) (actual time=1.015..1.015 rows=0 loops=1)

  • Sort Key: ((po_2.po_type)::character varying(255)), pi_1.proj_id, (CASE WHEN ((bschr_1.code)::text = '02'::text) THEN true ELSE false END), po_2.id, pi_1.id, (COALESCE(po_2.contract_doc_no, po_2.po_no)), po_2.objective_id, po_2.objective_snap, pi_1.budget_sub_cat_id, ((bschr_1.name)::character varying(500)) COLLATE thai, (COALESCE((pi_1.allow_rebate_retention_bond_start_date - 1), pi_1.retention_end_date))
  • Sort Method: quicksort Memory: 25kB
49. 0.002 0.961 ↓ 0.0 0 1

Nested Loop (cost=4.45..257.59 rows=4 width=1,268) (actual time=0.961..0.961 rows=0 loops=1)

50. 0.003 0.959 ↓ 0.0 0 1

Nested Loop (cost=4.31..256.90 rows=4 width=228) (actual time=0.959..0.959 rows=0 loops=1)

51. 0.956 0.956 ↓ 0.0 0 1

Seq Scan on po po_2 (cost=0.00..237.74 rows=1 width=172) (actual time=0.956..0.956 rows=0 loops=1)

  • Filter: ((po_type = 'HIGH_CONTRACT'::po_type) AND (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid) AND (po_status <> ALL ('{DRAFT,DRAFT_SEND_BACK,WAITING_FOR_AUTHORITY_APPROVAL,WAITING_FOR_APPROVAL,CANCELED,REJECTED,APPROVED,PRINTED,WAITING_FOR_RELEASE}'::po_status[])))
  • Rows Removed by Filter: 1095
52. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on po_item pi_1 (cost=4.31..19.11 rows=4 width=72) (never executed)

  • Recheck Cond: (po_id = po_2.id)
53. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on po_item_po_id_ord_key (cost=0.00..4.31 rows=4 width=0) (never executed)

  • Index Cond: (po_id = po_2.id)
54. 0.000 0.000 ↓ 0.0 0

Index Scan using budget_sub_category_high_rise_pkey on budget_sub_category_high_rise bschr_1 (cost=0.14..0.16 rows=1 width=1,048) (never executed)

  • Index Cond: (id = pi_1.budget_sub_cat_id)
55. 3.008 584.189 ↓ 9.6 769 1

Unique (cost=1,875.86..1,876.66 rows=80 width=729) (actual time=579.413..584.189 rows=769 loops=1)

56. 26.813 581.181 ↓ 275.7 22,056 1

Sort (cost=1,875.86..1,876.06 rows=80 width=729) (actual time=579.410..581.181 rows=22,056 loops=1)

  • Sort Key: pi_2.proj_id, pi_2.internal_order_id, pi_2.budget_sub_cat_high_rise_id
  • Sort Method: quicksort Memory: 3665kB
57. 25.900 554.368 ↓ 275.7 22,056 1

Nested Loop (cost=9.16..1,873.33 rows=80 width=729) (actual time=0.347..554.368 rows=22,056 loops=1)

58. 5.273 462.300 ↓ 51.5 22,056 1

Nested Loop (cost=8.88..655.86 rows=428 width=36) (actual time=0.311..462.300 rows=22,056 loops=1)

59. 5.449 143.511 ↓ 52.3 22,394 1

Nested Loop (cost=8.60..508.40 rows=428 width=31) (actual time=0.237..143.511 rows=22,394 loops=1)

60. 1.964 3.242 ↓ 214.0 214 1

Hash Join (cost=8.31..419.74 rows=1 width=20) (actual time=0.182..3.242 rows=214 loops=1)

  • Hash Cond: ((po_3.vendor_code)::text = (c_1.code)::text)
61. 1.200 1.200 ↑ 1.0 7,400 1

Seq Scan on sap_po po_3 (cost=0.00..392.00 rows=7,400 width=12) (actual time=0.037..1.200 rows=7,400 loops=1)

62. 0.038 0.078 ↑ 1.0 1 1

Hash (cost=8.30..8.30 rows=1 width=25) (actual time=0.078..0.078 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
63. 0.040 0.040 ↑ 1.0 1 1

Index Scan using contractor_pkey on contractor c_1 (cost=0.29..8.30 rows=1 width=25) (actual time=0.039..0.040 rows=1 loops=1)

  • Index Cond: (id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
64. 134.820 134.820 ↓ 2.0 105 214

Index Only Scan using sap_pr_po_map_uindex on sap_pr_po_map sppm (cost=0.29..88.14 rows=52 width=19) (actual time=0.066..0.630 rows=105 loops=214)

  • Index Cond: (po_item = po_3.po_item)
  • Heap Fetches: 22394
65. 313.516 313.516 ↑ 1.0 1 22,394

Index Scan using pr_index_pr_code on pr (cost=0.28..0.33 rows=1 width=27) (actual time=0.013..0.014 rows=1 loops=22,394)

  • Index Cond: ((pr_no)::text = (sppm.pr_doc_no)::text)
66. 66.168 66.168 ↑ 1.0 1 22,056

Index Scan using pr_item_pr_id_ord_key on pr_item pi_2 (cost=0.29..2.84 rows=1 width=68) (actual time=0.003..0.003 rows=1 loops=22,056)

  • Index Cond: ((pr_id = pr.id) AND (ord = sppm.pr_item))
67. 0.012 0.060 ↑ 1.0 62 1

Hash (cost=13.22..13.22 rows=62 width=20) (actual time=0.060..0.060 rows=62 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 12kB
68. 0.048 0.048 ↑ 1.0 62 1

Seq Scan on proj (cost=0.00..13.22 rows=62 width=20) (actual time=0.016..0.048 rows=62 loops=1)

  • Filter: (proj_type = 'LOW_RISE'::proj_type)
  • Rows Removed by Filter: 36
69. 0.041 2,552.596 ↓ 14.5 58 1

Unique (cost=308,337.79..308,337.85 rows=4 width=1,701) (actual time=2,552.542..2,552.596 rows=58 loops=1)

70. 0.413 2,552.555 ↓ 46.8 187 1

Sort (cost=308,337.79..308,337.80 rows=4 width=1,701) (actual time=2,552.540..2,552.555 rows=187 loops=1)

  • Sort Key: ('MIGRATE_LIVE1_CONTRACTOR'::text), proj_2.id, io_1.id, (COALESCE(migrate_live1_contractor.is_main, false)), migrate_live1_contractor.warranty_expiry
  • Sort Method: quicksort Memory: 51kB
71. 0.913 2,552.142 ↓ 46.8 187 1

Merge Anti Join (cost=296,887.93..308,337.75 rows=4 width=1,701) (actual time=1,513.402..2,552.142 rows=187 loops=1)

  • Merge Cond: (proj_2.id = "*SELECT* 1_1".proj_id)
  • Join Filter: ((NOT ((NULL::uuid) IS DISTINCT FROM io_1.id)) AND ("*SELECT* 1_1".contractor_id = c_2.id) AND ((('MIGRATE_LIVE1_CONTRACTOR'::text) = 'MIGRATE_LIVE1_CONTRACTOR'::text) OR ((('MIGRATE_LIVE1_CONTRACTOR'::text) = 'MIGRATE_LIVE1_SUPPLIER'::text) AND (NOT ((NULL::date) IS DISTINCT FROM migrate_live1_contractor.warranty_expiry)))))
  • Rows Removed by Join Filter: 1954
72. 638.128 2,028.044 ↓ 60.8 243 1

Nested Loop Left Join (cost=293,723.53..305,168.70 rows=4 width=89) (actual time=991.328..2,028.044 rows=243 loops=1)

  • Join Filter: (((((migrate_live1_contractor.io_code)::character varying(255)))::text = (io_1.io_code)::text) AND (io_1.proj_id = proj_2.id))
  • Rows Removed by Join Filter: 5329298
73. 3.586 980.704 ↓ 60.8 243 1

Nested Loop (cost=293,723.53..299,598.76 rows=4 width=589) (actual time=974.775..980.704 rows=243 loops=1)

  • Join Filter: ((((migrate_live1_contractor.proj_code)::character varying(255)))::text = (proj_2.code)::text)
  • Rows Removed by Join Filter: 26975
74. 0.122 0.122 ↑ 1.0 62 1

Index Scan using proj_pkey on proj proj_2 (cost=0.14..57.53 rows=62 width=25) (actual time=0.013..0.122 rows=62 loops=1)

  • Filter: (proj_type = 'LOW_RISE'::proj_type)
  • Rows Removed by Filter: 36
75. 2.129 976.996 ↓ 36.6 439 62

Materialize (cost=293,723.39..299,530.11 rows=12 width=1,085) (actual time=15.718..15.758 rows=439 loops=62)

76. 23.151 974.867 ↓ 36.6 439 1

Merge Join (cost=293,723.39..299,530.05 rows=12 width=1,085) (actual time=974.512..974.867 rows=439 loops=1)

  • Merge Cond: ((((migrate_live1_contractor.code)::character varying(255)))::text = (c_2.code)::text)
77. 66.401 951.677 ↑ 1.1 176,301 1

Unique (cost=293,715.08..297,102.22 rows=193,551 width=1,585) (actual time=850.366..951.677 rows=176,301 loops=1)

78. 761.223 885.276 ↑ 1.1 176,306 1

Sort (cost=293,715.08..294,198.95 rows=193,551 width=1,585) (actual time=850.365..885.276 rows=176,306 loops=1)

  • Sort Key: ((migrate_live1_contractor.code)::character varying(255)) COLLATE thai, ((migrate_live1_contractor.proj_code)::character varying(255)) COLLATE thai, ((migrate_live1_contractor.io_code)::character varying(255)) COLLATE thai, migrate_live1_contractor.is_main, migrate_live1_contractor.warranty_expiry, ('MIGRATE_LIVE1_CONTRACTOR'::text)
  • Sort Method: external merge Disk: 10864kB
79. 24.865 124.053 ↑ 1.0 193,551 1

Append (cost=0.00..9,452.02 rows=193,551 width=1,585) (actual time=0.015..124.053 rows=193,551 loops=1)

80. 6.739 6.739 ↑ 1.0 22,687 1

Seq Scan on migrate_live1_contractor (cost=0.00..724.87 rows=22,687 width=1,585) (actual time=0.015..6.739 rows=22,687 loops=1)

81. 29.804 92.449 ↑ 1.0 170,864 1

Subquery Scan on *SELECT* 2_1 (cost=0.00..8,500.28 rows=170,864 width=1,585) (actual time=0.050..92.449 rows=170,864 loops=1)

82. 62.645 62.645 ↑ 1.0 170,864 1

Seq Scan on migrate_live1_supplier (cost=0.00..6,791.64 rows=170,864 width=59) (actual time=0.049..62.645 rows=170,864 loops=1)

83. 0.021 0.039 ↑ 1.0 1 1

Sort (cost=8.31..8.32 rows=1 width=25) (actual time=0.038..0.039 rows=1 loops=1)

  • Sort Key: c_2.code COLLATE thai
  • Sort Method: quicksort Memory: 25kB
84. 0.018 0.018 ↑ 1.0 1 1

Index Scan using contractor_pkey on contractor c_2 (cost=0.29..8.30 rows=1 width=25) (actual time=0.017..0.018 rows=1 loops=1)

  • Index Cond: (id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
85. 401.474 409.212 ↑ 1.3 21,932 243

Materialize (cost=0.00..3,695.53 rows=27,769 width=43) (actual time=0.000..1.684 rows=21,932 loops=243)

86. 7.738 7.738 ↑ 1.0 27,769 1

Seq Scan on internal_order io_1 (cost=0.00..3,556.69 rows=27,769 width=43) (actual time=0.016..7.738 rows=27,769 loops=1)

87. 0.305 523.185 ↓ 26.9 2,449 1

Materialize (cost=3,164.40..3,168.72 rows=91 width=52) (actual time=522.070..523.185 rows=2,449 loops=1)

88. 0.532 522.880 ↓ 5.7 515 1

Unique (cost=3,164.40..3,167.58 rows=91 width=249) (actual time=522.068..522.880 rows=515 loops=1)

89. 0.935 522.348 ↓ 5.7 515 1

Sort (cost=3,164.40..3,164.62 rows=91 width=249) (actual time=522.067..522.348 rows=515 loops=1)

  • Sort Key: "*SELECT* 1_1".proj_id, proj_3.proj_type, (NULL::uuid), (false), (NULL::uuid), (NULL::uuid), (NULL::character varying(255)), (NULL::uuid), (NULL::character varying(500)), (NULL::uuid), ((NULL::character varying(501))::character varying(501)) COLLATE thai, (NULL::date), ('PROJ_CONTRACTOR'::text)
  • Sort Method: quicksort Memory: 133kB
90. 0.222 521.413 ↓ 8.4 768 1

Hash Join (cost=3,159.37..3,161.44 rows=91 width=249) (actual time=520.969..521.413 rows=768 loops=1)

  • Hash Cond: ("*SELECT* 1_1".proj_id = proj_3.id)
91. 0.714 521.130 ↓ 8.5 769 1

HashAggregate (cost=3,145.16..3,146.07 rows=91 width=245) (actual time=520.898..521.130 rows=769 loops=1)

  • Group Key: ('PROJ_CONTRACTOR'::text), "*SELECT* 1_1".proj_id, (NULL::uuid), "*SELECT* 1_1".contractor_id, (false), (NULL::uuid), (NULL::uuid), (NULL::character varying(255)), (NULL::uuid), (NULL::character varying(500)), (NULL::uuid), ((NULL::character varying(501))::character varying(501)), (NULL::date)
92. 0.096 520.416 ↓ 8.5 769 1

Append (cost=31.24..3,142.20 rows=91 width=245) (actual time=515.422..520.416 rows=769 loops=1)

93. 0.001 0.031 ↓ 0.0 0 1

Subquery Scan on *SELECT* 1_1 (cost=31.24..31.27 rows=2 width=1,697) (actual time=0.031..0.031 rows=0 loops=1)

94. 0.000 0.030 ↓ 0.0 0 1

Unique (cost=31.24..31.25 rows=2 width=1,697) (actual time=0.030..0.030 rows=0 loops=1)

95. 0.003 0.030 ↓ 0.0 0 1

Sort (cost=31.24..31.24 rows=2 width=1,697) (actual time=0.029..0.030 rows=0 loops=1)

  • Sort Key: proj_1_1.id
  • Sort Method: quicksort Memory: 25kB
96. 0.002 0.027 ↓ 0.0 0 1

Nested Loop (cost=9.94..31.23 rows=2 width=1,697) (actual time=0.027..0.027 rows=0 loops=1)

97. 0.013 0.013 ↑ 1.0 1 1

Index Only Scan using contractor_pkey on contractor c_3 (cost=0.29..8.30 rows=1 width=16) (actual time=0.013..0.013 rows=1 loops=1)

  • Index Cond: (id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
  • Heap Fetches: 1
98. 0.003 0.012 ↓ 0.0 0 1

Hash Join (cost=9.66..22.91 rows=2 width=32) (actual time=0.012..0.012 rows=0 loops=1)

  • Hash Cond: (proj_1_1.id = pc_1.proj_id)
99. 0.002 0.002 ↑ 98.0 1 1

Seq Scan on proj proj_1_1 (cost=0.00..12.98 rows=98 width=16) (actual time=0.002..0.002 rows=1 loops=1)

100. 0.001 0.007 ↓ 0.0 0 1

Hash (cost=9.63..9.63 rows=2 width=32) (actual time=0.007..0.007 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
101. 0.001 0.006 ↓ 0.0 0 1

Bitmap Heap Scan on proj_contractor pc_1 (cost=4.29..9.63 rows=2 width=32) (actual time=0.006..0.006 rows=0 loops=1)

  • Recheck Cond: (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
102. 0.005 0.005 ↓ 0.0 0 1

Bitmap Index Scan on proj_contractor_uindex (cost=0.00..4.29 rows=2 width=0) (actual time=0.004..0.005 rows=0 loops=1)

  • Index Cond: (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
103. 0.001 0.393 ↓ 0.0 0 1

Subquery Scan on *SELECT* 2_2 (cost=268.56..268.71 rows=4 width=784) (actual time=0.393..0.393 rows=0 loops=1)

104. 0.000 0.392 ↓ 0.0 0 1

Unique (cost=268.56..268.67 rows=4 width=1,268) (actual time=0.392..0.392 rows=0 loops=1)

105. 0.006 0.392 ↓ 0.0 0 1

Sort (cost=268.56..268.57 rows=4 width=1,268) (actual time=0.391..0.392 rows=0 loops=1)

  • Sort Key: ((po_4.po_type)::character varying(255)), po_4.proj_id, pi_3.internal_order_id, (CASE WHEN ((po_4.po_type = 'LOW_CONTRACT'::po_type) AND (po_4.contractor_id = io_2.main_contractor_id)) THEN true ELSE false END), po_4.id, (CASE WHEN (po_4.po_type = 'LOW_CONTRACT'::po_type) THEN pi_3.id ELSE NULL::uuid END), (COALESCE(po_4.contract_doc_no, po_4.po_no)), po_4.objective_id, po_4.objective_snap, (COALESCE((pi_3.allow_rebate_retention_bond_start_date - 1), pi_3.retention_end_date))
  • Sort Method: quicksort Memory: 25kB
106. 0.001 0.386 ↓ 0.0 0 1

Nested Loop Left Join (cost=4.60..268.52 rows=4 width=1,268) (actual time=0.386..0.386 rows=0 loops=1)

107. 0.001 0.385 ↓ 0.0 0 1

Nested Loop (cost=4.31..256.90 rows=4 width=228) (actual time=0.385..0.385 rows=0 loops=1)

108. 0.384 0.384 ↓ 0.0 0 1

Seq Scan on po po_4 (cost=0.00..237.74 rows=1 width=188) (actual time=0.384..0.384 rows=0 loops=1)

  • Filter: ((po_type = ANY ('{LOW_CONTRACT,LOW_PO_HOUSE}'::po_type[])) AND (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid) AND (po_status <> ALL ('{DRAFT,DRAFT_SEND_BACK,WAITING_FOR_AUTHORITY_APPROVAL,WAITING_FOR_APPROVAL,CANCELED,REJECTED,APPROVED,PRINTED,WAITING_FOR_RELEASE}'::po_status[])))
  • Rows Removed by Filter: 1095
109. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on po_item pi_3 (cost=4.31..19.11 rows=4 width=56) (never executed)

  • Recheck Cond: (po_id = po_4.id)
110. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on po_item_po_id_ord_key (cost=0.00..4.31 rows=4 width=0) (never executed)

  • Index Cond: (po_id = po_4.id)
111. 0.000 0.000 ↓ 0.0 0

Index Scan using internal_order_pkey on internal_order io_2 (cost=0.29..2.89 rows=1 width=32) (never executed)

  • Index Cond: (id = pi_3.internal_order_id)
112. 0.001 0.297 ↓ 0.0 0 1

Subquery Scan on *SELECT* 3_1 (cost=706.95..706.98 rows=1 width=784) (actual time=0.297..0.297 rows=0 loops=1)

113. 0.000 0.296 ↓ 0.0 0 1

Unique (cost=706.95..706.97 rows=1 width=1,268) (actual time=0.296..0.296 rows=0 loops=1)

114. 0.006 0.296 ↓ 0.0 0 1

Sort (cost=706.95..706.95 rows=1 width=1,268) (actual time=0.296..0.296 rows=0 loops=1)

  • Sort Key: ((po_5.po_type)::character varying(255)), po_5.proj_id, po_5.id, (COALESCE(po_5.contract_doc_no, po_5.po_no)), po_5.objective_id, po_5.objective_snap, po_5.budget_sub_cat_id, ((bschr_2.name)::character varying(500)) COLLATE thai, (COALESCE(((max(po_item_1.allow_rebate_retention_bond_start_date)) - 1), (max(po_item_1.retention_end_date))))
  • Sort Method: quicksort Memory: 25kB
115. 0.000 0.290 ↓ 0.0 0 1

Nested Loop Left Join (cost=680.26..706.94 rows=1 width=1,268) (actual time=0.290..0.290 rows=0 loops=1)

  • Join Filter: (po_5.budget_sub_cat_id = bschr_2.id)
116. 0.005 0.290 ↓ 0.0 0 1

Hash Right Join (cost=680.26..705.05 rows=1 width=212) (actual time=0.290..0.290 rows=0 loops=1)

  • Hash Cond: (po_item_1.po_id = po_5.id)
117. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=439.77..450.72 rows=1,095 width=24) (never executed)

  • Group Key: po_item_1.po_id
118. 0.000 0.000 ↓ 0.0 0

Seq Scan on po_item po_item_1 (cost=0.00..409.44 rows=4,044 width=24) (never executed)

119. 0.001 0.285 ↓ 0.0 0 1

Hash (cost=240.48..240.48 rows=1 width=204) (actual time=0.285..0.285 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
120. 0.284 0.284 ↓ 0.0 0 1

Seq Scan on po po_5 (cost=0.00..240.48 rows=1 width=204) (actual time=0.284..0.284 rows=0 loops=1)

  • Filter: ((contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid) AND (po_type = ANY ('{LOW_PO_UTILITY,LOW_CONTRACT_UTILITY,HIGH_PO_BUDGET_CTRL,HIGH_PO_OTHER}'::po_type[])) AND (po_status <> ALL ('{DRAFT,DRAFT_SEND_BACK,WAITING_FOR_AUTHORITY_APPROVAL,WAITING_FOR_APPROVAL,CANCELED,REJECTED,APPROVED,PRINTED,WAITING_FOR_RELEASE}'::po_status[])))
  • Rows Removed by Filter: 1095
121. 0.000 0.000 ↓ 0.0 0

Seq Scan on budget_sub_category_high_rise bschr_2 (cost=0.00..1.39 rows=39 width=532) (never executed)

122. 0.001 0.234 ↓ 0.0 0 1

Subquery Scan on *SELECT* 4_1 (cost=257.63..257.79 rows=4 width=784) (actual time=0.233..0.234 rows=0 loops=1)

123. 0.000 0.233 ↓ 0.0 0 1

Unique (cost=257.63..257.75 rows=4 width=1,268) (actual time=0.233..0.233 rows=0 loops=1)

124. 0.006 0.233 ↓ 0.0 0 1

Sort (cost=257.63..257.64 rows=4 width=1,268) (actual time=0.232..0.233 rows=0 loops=1)

  • Sort Key: ((po_6.po_type)::character varying(255)), pi_4.proj_id, (CASE WHEN ((bschr_3.code)::text = '02'::text) THEN true ELSE false END), po_6.id, pi_4.id, (COALESCE(po_6.contract_doc_no, po_6.po_no)), po_6.objective_id, po_6.objective_snap, pi_4.budget_sub_cat_id, ((bschr_3.name)::character varying(500)) COLLATE thai, (COALESCE((pi_4.allow_rebate_retention_bond_start_date - 1), pi_4.retention_end_date))
  • Sort Method: quicksort Memory: 25kB
125. 0.001 0.227 ↓ 0.0 0 1

Nested Loop (cost=4.45..257.59 rows=4 width=1,268) (actual time=0.227..0.227 rows=0 loops=1)

126. 0.000 0.226 ↓ 0.0 0 1

Nested Loop (cost=4.31..256.90 rows=4 width=228) (actual time=0.226..0.226 rows=0 loops=1)

127. 0.226 0.226 ↓ 0.0 0 1

Seq Scan on po po_6 (cost=0.00..237.74 rows=1 width=172) (actual time=0.226..0.226 rows=0 loops=1)

  • Filter: ((po_type = 'HIGH_CONTRACT'::po_type) AND (contractor_id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid) AND (po_status <> ALL ('{DRAFT,DRAFT_SEND_BACK,WAITING_FOR_AUTHORITY_APPROVAL,WAITING_FOR_APPROVAL,CANCELED,REJECTED,APPROVED,PRINTED,WAITING_FOR_RELEASE}'::po_status[])))
  • Rows Removed by Filter: 1095
128. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on po_item pi_4 (cost=4.31..19.11 rows=4 width=72) (never executed)

  • Recheck Cond: (po_id = po_6.id)
129. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on po_item_po_id_ord_key (cost=0.00..4.31 rows=4 width=0) (never executed)

  • Index Cond: (po_id = po_6.id)
130. 0.000 0.000 ↓ 0.0 0

Index Scan using budget_sub_category_high_rise_pkey on budget_sub_category_high_rise bschr_3 (cost=0.14..0.16 rows=1 width=1,048) (never executed)

  • Index Cond: (id = pi_4.budget_sub_cat_id)
131. 3.039 519.365 ↓ 9.6 769 1

Unique (cost=1,875.86..1,876.66 rows=80 width=729) (actual time=514.466..519.365 rows=769 loops=1)

132. 23.887 516.326 ↓ 275.7 22,056 1

Sort (cost=1,875.86..1,876.06 rows=80 width=729) (actual time=514.464..516.326 rows=22,056 loops=1)

  • Sort Key: pi_5.proj_id, pi_5.internal_order_id, pi_5.budget_sub_cat_high_rise_id
  • Sort Method: quicksort Memory: 3665kB
133. 31.674 492.439 ↓ 275.7 22,056 1

Nested Loop (cost=9.16..1,873.33 rows=80 width=729) (actual time=0.097..492.439 rows=22,056 loops=1)

134. 1.764 416.653 ↓ 51.5 22,056 1

Nested Loop (cost=8.88..655.86 rows=428 width=36) (actual time=0.087..416.653 rows=22,056 loops=1)

135. 4.154 123.767 ↓ 52.3 22,394 1

Nested Loop (cost=8.60..508.40 rows=428 width=31) (actual time=0.051..123.767 rows=22,394 loops=1)

136. 2.061 3.411 ↓ 214.0 214 1

Hash Join (cost=8.31..419.74 rows=1 width=20) (actual time=0.034..3.411 rows=214 loops=1)

  • Hash Cond: ((po_7.vendor_code)::text = (c_4.code)::text)
137. 1.344 1.344 ↑ 1.0 7,400 1

Seq Scan on sap_po po_7 (cost=0.00..392.00 rows=7,400 width=12) (actual time=0.006..1.344 rows=7,400 loops=1)

138. 0.002 0.006 ↑ 1.0 1 1

Hash (cost=8.30..8.30 rows=1 width=25) (actual time=0.006..0.006 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
139. 0.004 0.004 ↑ 1.0 1 1

Index Scan using contractor_pkey on contractor c_4 (cost=0.29..8.30 rows=1 width=25) (actual time=0.004..0.004 rows=1 loops=1)

  • Index Cond: (id = '072c2e39-cbfe-4084-b93c-dd880b8742cf'::uuid)
140. 116.202 116.202 ↓ 2.0 105 214

Index Only Scan using sap_pr_po_map_uindex on sap_pr_po_map sppm_1 (cost=0.29..88.14 rows=52 width=19) (actual time=0.070..0.543 rows=105 loops=214)

  • Index Cond: (po_item = po_7.po_item)
  • Heap Fetches: 22394
141. 291.122 291.122 ↑ 1.0 1 22,394

Index Scan using pr_index_pr_code on pr pr_1 (cost=0.28..0.33 rows=1 width=27) (actual time=0.012..0.013 rows=1 loops=22,394)

  • Index Cond: ((pr_no)::text = (sppm_1.pr_doc_no)::text)
142. 44.112 44.112 ↑ 1.0 1 22,056

Index Scan using pr_item_pr_id_ord_key on pr_item pi_5 (cost=0.29..2.84 rows=1 width=68) (actual time=0.002..0.002 rows=1 loops=22,056)

  • Index Cond: ((pr_id = pr_1.id) AND (ord = sppm_1.pr_item))
143. 0.019 0.061 ↑ 1.0 98 1

Hash (cost=12.98..12.98 rows=98 width=20) (actual time=0.061..0.061 rows=98 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 13kB
144. 0.042 0.042 ↑ 1.0 98 1

Seq Scan on proj proj_3 (cost=0.00..12.98 rows=98 width=20) (actual time=0.009..0.042 rows=98 loops=1)

Planning time : 20.164 ms
Execution time : 3,153.222 ms