explain.depesz.com

PostgreSQL's explain analyze made readable

Result: mTy

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 8,101.913 ↑ 1.0 20 1

Limit (cost=1,664,855.00..1,664,885.20 rows=20 width=602) (actual time=8,101.751..8,101.913 rows=20 loops=1)

2. 0.195 8,101.909 ↑ 9.5 21 1

GroupAggregate (cost=1,664,853.49..1,665,155.42 rows=200 width=602) (actual time=8,101.741..8,101.909 rows=21 loops=1)

3. 0.137 8,101.714 ↑ 11.6 24 1

Sort (cost=1,664,853.49..1,664,854.19 rows=279 width=602) (actual time=8,101.714..8,101.714 rows=24 loops=1)

  • Sort Key: foo.sample_date_time, foo.sample_sno, foo.sample_assertion_batch, foo.sample_type, foo.sample_date, foo.collection_center, foo.mr_no, foo.patient_id, foo.sample_qty, foo.ih_name, foo.sample_status, foo.assertion_time, foo.rejected_time, foo.conducted, foo.sample_type_id, foo.collection_center_id, foo.visit_type, foo.center_id, foo.sample_collection_id, foo.patient_name, foo.outsource_dest_id, foo.outsource_name, foo.orig_sample_no, foo.transfer_time, foo.transfer_other_details, foo.receipt_time, foo.receipt_other_details, foo.bill_status, foo.charge_head
  • Sort Method: quicksort Memory: 45kB
4. 0.007 8,101.577 ↑ 4.6 61 1

Subquery Scan on foo (cost=1,664,695.69..1,664,842.16 rows=279 width=602) (actual time=8,101.550..8,101.577 rows=61 loops=1)

5. 0.168 8,101.570 ↑ 4.6 61 1

HashAggregate (cost=1,664,695.69..1,664,839.37 rows=279 width=366) (actual time=8,101.548..8,101.570 rows=61 loops=1)

6. 3.039 8,101.402 ↑ 4.2 67 1

Hash Join (cost=620,214.91..1,664,669.88 rows=279 width=366) (actual time=8,058.316..8,101.402 rows=67 loops=1)

  • Hash Cond: (sc.sample_type_id = st.sample_type_id)
7. 0.075 8,098.214 ↑ 4.2 67 1

Nested Loop (cost=620,113.81..1,664,424.04 rows=279 width=351) (actual time=8,057.992..8,098.214 rows=67 loops=1)

8. 0.012 8,097.670 ↑ 4.2 67 1

Nested Loop (cost=620,113.25..1,663,976.87 rows=279 width=363) (actual time=8,057.978..8,097.670 rows=67 loops=1)

9. 0.047 8,097.189 ↑ 4.2 67 1

Nested Loop Left Join (cost=620,112.69..1,663,367.18 rows=279 width=353) (actual time=8,057.965..8,097.189 rows=67 loops=1)

10. 0.036 8,097.142 ↑ 4.2 67 1

Nested Loop Left Join (cost=620,112.26..1,662,993.79 rows=279 width=348) (actual time=8,057.963..8,097.142 rows=67 loops=1)

11. 0.034 8,097.106 ↑ 4.2 67 1

Hash Left Join (cost=620,111.83..1,662,372.03 rows=279 width=348) (actual time=8,057.960..8,097.106 rows=67 loops=1)

  • Hash Cond: (pr.collection_center_id = scc.collection_center_id)
12. 0.091 8,097.070 ↑ 4.2 67 1

Nested Loop (cost=620,110.80..1,662,367.17 rows=279 width=339) (actual time=8,057.950..8,097.070 rows=67 loops=1)

13. 0.022 8,096.644 ↑ 4.5 67 1

Hash Left Join (cost=620,110.36..1,661,617.32 rows=299 width=337) (actual time=8,057.934..8,096.644 rows=67 loops=1)

  • Hash Cond: ((isr.orig_lab_name)::text = (ih.hospital_id)::text)
14. 0.006 8,096.614 ↑ 4.5 67 1

Nested Loop Left Join (cost=620,108.95..1,661,611.81 rows=299 width=334) (actual time=8,057.922..8,096.614 rows=67 loops=1)

  • Join Filter: ((isr.incoming_visit_id)::text = (isrd.incoming_visit_id)::text)
15. 0.043 8,096.474 ↑ 4.5 67 1

Hash Left Join (cost=620,108.53..1,661,227.76 rows=299 width=317) (actual time=8,057.915..8,096.474 rows=67 loops=1)

  • Hash Cond: ((pd.salutation)::text = (sm.salutation_id)::text)
16. 0.043 8,096.422 ↑ 4.5 67 1

Nested Loop Left Join (cost=620,107.05..1,661,222.17 rows=299 width=321) (actual time=8,057.892..8,096.422 rows=67 loops=1)

17. 0.039 8,095.843 ↑ 4.5 67 1

Hash Join (cost=620,106.62..1,660,809.76 rows=299 width=288) (actual time=8,057.875..8,095.843 rows=67 loops=1)

  • Hash Cond: ((d.ddept_id)::text = (diagnostics_departments.ddept_id)::text)
18. 0.343 8,095.796 ↑ 4.5 67 1

Hash Left Join (cost=620,105.35..1,660,804.37 rows=299 width=275) (actual time=8,057.858..8,095.796 rows=67 loops=1)

  • Hash Cond: ((sc.patient_id)::text = (isr.incoming_visit_id)::text)
  • Filter: (COALESCE(pr.center_id, isr.center_id) = 13)
  • Rows Removed by Filter: 327
19. 0.426 8,006.086 ↑ 151.9 394 1

Nested Loop Left Join (cost=610,718.95..1,650,452.12 rows=59,833 width=228) (actual time=7,965.819..8,006.086 rows=394 loops=1)

20. 0.251 8,003.690 ↑ 151.9 394 1

Hash Join (cost=610,718.51..1,369,466.47 rows=59,833 width=187) (actual time=7,965.789..8,003.690 rows=394 loops=1)

  • Hash Cond: ((COALESCE(tp.test_id, tpr.test_id))::text = (d.test_id)::text)
21. 1,450.789 8,001.948 ↑ 151.9 394 1

Merge Right Join (cost=610,168.06..1,368,018.52 rows=59,833 width=154) (actual time=7,964.289..8,001.948 rows=394 loops=1)

  • Merge Cond: (tp.sample_collection_id = (CASE WHEN (sc.sample_status = 'R'::bpchar) THEN sr.test_prescribed_id ELSE sc.sample_collection_id END))
  • Filter: ((CASE WHEN (sc.sample_status = 'R'::bpchar) THEN tpr.conducted ELSE tp.conducted END)::text = ANY ('{N,NRN}'::text[]))
  • Rows Removed by Filter: 72
22. 2,506.552 2,506.552 ↑ 1.2 6,466,843 1

Index Scan using idx_tests_prescribed_sample_collection_id on tests_prescribed tp (cost=0.43..585,468.89 rows=7,551,672 width=19) (actual time=0.010..2,506.552 rows=6,466,843 loops=1)

23. 0.211 4,044.607 ↑ 284.3 466 1

Sort (cost=610,167.63..610,498.89 rows=132,504 width=145) (actual time=4,044.546..4,044.607 rows=466 loops=1)

  • Sort Key: (CASE WHEN (sc.sample_status = 'R'::bpchar) THEN sr.test_prescribed_id ELSE sc.sample_collection_id END)
  • Sort Method: quicksort Memory: 70kB
24. 523.210 4,044.396 ↑ 515.6 257 1

Hash Left Join (cost=550,887.81..598,894.40 rows=132,504 width=145) (actual time=3,519.832..4,044.396 rows=257 loops=1)

  • Hash Cond: (CASE WHEN (sc.sample_status = 'R'::bpchar) THEN sr.test_prescribed_id ELSE sc.sample_collection_id END = tpr.prescribed_id)
25. 0.772 727.910 ↑ 515.6 257 1

Hash Left Join (cost=143,117.19..144,767.40 rows=132,504 width=130) (actual time=726.228..727.910 rows=257 loops=1)

  • Hash Cond: (sc.outsource_dest_id = dom.outsource_dest_id)
  • Filter: ((dom.outsource_dest_type IS NULL) OR (dom.outsource_dest_type <> 'C'::bpchar))
  • Rows Removed by Filter: 3891
26. 4.211 727.002 ↑ 36.3 4,148 1

Hash Right Join (cost=143,106.35..143,867.34 rows=150,471 width=105) (actual time=726.034..727.002 rows=4,148 loops=1)

  • Hash Cond: (sr.sample_collection_id = sc.sample_collection_id)
27. 1.719 1.719 ↑ 1.0 25,665 1

Seq Scan on sample_rejections sr (cost=0.00..395.65 rows=25,665 width=8) (actual time=0.005..1.719 rows=25,665 loops=1)

28. 1.982 721.072 ↑ 36.3 4,148 1

Hash (cost=141,225.46..141,225.46 rows=150,471 width=101) (actual time=721.072..721.072 rows=4,148 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 421kB
29. 719.090 719.090 ↑ 36.3 4,148 1

Seq Scan on sample_collection sc (cost=0.00..141,225.46 rows=150,471 width=101) (actual time=412.392..719.090 rows=4,148 loops=1)

  • Filter: ((sample_status = 'C'::bpchar) AND (sample_receive_status = 'R'::bpchar) AND (sample_status = ANY ('{C,A,R}'::bpchar[])) AND ((sample_date)::date >= '2018-12-29'::date))
  • Rows Removed by Filter: 3095660
30. 0.015 0.136 ↑ 1.0 67 1

Hash (cost=10.00..10.00 rows=67 width=31) (actual time=0.136..0.136 rows=67 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 4kB
31. 0.021 0.121 ↑ 1.0 67 1

Hash Left Join (cost=6.84..10.00 rows=67 width=31) (actual time=0.077..0.121 rows=67 loops=1)

  • Hash Cond: ((dom.outsource_dest)::text = (hcm.center_id)::text)
32. 0.039 0.076 ↑ 1.0 67 1

Hash Left Join (cost=2.33..4.84 rows=67 width=28) (actual time=0.047..0.076 rows=67 loops=1)

  • Hash Cond: ((dom.outsource_dest)::text = (om.oh_id)::text)
33. 0.010 0.010 ↑ 1.0 67 1

Seq Scan on diag_outsource_master dom (cost=0.00..1.67 rows=67 width=15) (actual time=0.003..0.010 rows=67 loops=1)

34. 0.016 0.027 ↑ 1.0 59 1

Hash (cost=1.59..1.59 rows=59 width=24) (actual time=0.027..0.027 rows=59 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 4kB
35. 0.011 0.011 ↑ 1.0 59 1

Seq Scan on outhouse_master om (cost=0.00..1.59 rows=59 width=24) (actual time=0.004..0.011 rows=59 loops=1)

36. 0.011 0.024 ↑ 1.0 23 1

Hash (cost=4.23..4.23 rows=23 width=16) (actual time=0.024..0.024 rows=23 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
37. 0.013 0.013 ↑ 1.0 23 1

Seq Scan on hospital_center_master hcm (cost=0.00..4.23 rows=23 width=16) (actual time=0.004..0.013 rows=23 loops=1)

38. 1,350.957 2,793.276 ↓ 1.0 7,554,345 1

Hash (cost=276,500.72..276,500.72 rows=7,551,672 width=15) (actual time=2,793.276..2,793.276 rows=7,554,345 loops=1)

  • Buckets: 131072 Batches: 8 Memory Usage: 46133kB
39. 1,442.319 1,442.319 ↓ 1.0 7,554,345 1

Seq Scan on tests_prescribed tpr (cost=0.00..276,500.72 rows=7,551,672 width=15) (actual time=0.004..1,442.319 rows=7,554,345 loops=1)

40. 0.524 1.491 ↑ 1.0 1,798 1

Hash (cost=527.98..527.98 rows=1,798 width=49) (actual time=1.491..1.491 rows=1,798 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 143kB
41. 0.967 0.967 ↑ 1.0 1,798 1

Seq Scan on diagnostics d (cost=0.00..527.98 rows=1,798 width=49) (actual time=0.002..0.967 rows=1,798 loops=1)

42. 1.970 1.970 ↑ 1.0 1 394

Index Scan using patient_registration_pkey on patient_registration pr (cost=0.43..4.69 rows=1 width=41) (actual time=0.005..0.005 rows=1 loops=394)

  • Index Cond: ((patient_id)::text = (sc.patient_id)::text)
43. 44.515 89.367 ↑ 1.0 225,307 1

Hash (cost=6,570.07..6,570.07 rows=225,307 width=62) (actual time=89.367..89.367 rows=225,307 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 21046kB
44. 44.852 44.852 ↑ 1.0 225,307 1

Seq Scan on incoming_sample_registration isr (cost=0.00..6,570.07 rows=225,307 width=62) (actual time=0.003..44.852 rows=225,307 loops=1)

45. 0.005 0.008 ↑ 1.0 12 1

Hash (cost=1.12..1.12 rows=12 width=23) (actual time=0.008..0.008 rows=12 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
46. 0.003 0.003 ↑ 1.0 12 1

Seq Scan on diagnostics_departments (cost=0.00..1.12 rows=12 width=23) (actual time=0.002..0.003 rows=12 loops=1)

47. 0.536 0.536 ↑ 1.0 1 67

Index Scan using patient_details_pkey on patient_details pd (cost=0.43..1.37 rows=1 width=48) (actual time=0.008..0.008 rows=1 loops=67)

  • Index Cond: ((mr_no)::text = (pr.mr_no)::text)
48. 0.004 0.009 ↑ 1.0 21 1

Hash (cost=1.21..1.21 rows=21 width=14) (actual time=0.009..0.009 rows=21 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
49. 0.005 0.005 ↑ 1.0 21 1

Seq Scan on salutation_master sm (cost=0.00..1.21 rows=21 width=14) (actual time=0.002..0.005 rows=21 loops=1)

50. 0.134 0.134 ↓ 0.0 0 67

Index Scan using incoming_sample_registration_details_pkey on incoming_sample_registration_details isrd (cost=0.42..1.27 rows=1 width=30) (actual time=0.002..0.002 rows=0 loops=67)

  • Index Cond: (tp.prescribed_id = prescribed_id)
51. 0.003 0.008 ↑ 1.0 18 1

Hash (cost=1.18..1.18 rows=18 width=17) (actual time=0.008..0.008 rows=18 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
52. 0.005 0.005 ↑ 1.0 18 1

Seq Scan on incoming_hospitals ih (cost=0.00..1.18 rows=18 width=17) (actual time=0.002..0.005 rows=18 loops=1)

53. 0.335 0.335 ↑ 1.0 1 67

Index Scan using bac_activity_id_index on bill_activity_charge bac (cost=0.45..2.50 rows=1 width=17) (actual time=0.005..0.005 rows=1 loops=67)

  • Index Cond: (COALESCE((tp.prescribed_id)::text, (tpr.prescribed_id)::text) = (activity_id)::text)
  • Filter: ((activity_code)::text = 'DIA'::text)
54. 0.000 0.002 ↑ 1.0 1 1

Hash (cost=1.01..1.01 rows=1 width=13) (actual time=0.002..0.002 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
55. 0.002 0.002 ↑ 1.0 1 1

Seq Scan on sample_collection_centers scc (cost=0.00..1.01 rows=1 width=13) (actual time=0.002..0.002 rows=1 loops=1)

56. 0.000 0.000 ↓ 0.0 0 67

Index Scan using tests_prescribed_pkey on tests_prescribed tp1 (cost=0.43..2.22 rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=67)

  • Index Cond: (prescribed_id = isrd.source_test_prescribed)
57. 0.000 0.000 ↓ 0.0 0 67

Index Scan using sample_collection_id_pkey on sample_collection sc1 (cost=0.43..1.33 rows=1 width=13) (actual time=0.000..0.000 rows=0 loops=67)

  • Index Cond: (sample_collection_id = tp1.sample_collection_id)
58. 0.469 0.469 ↑ 1.0 1 67

Index Scan using bill_charge_pkey on bill_charge bc (cost=0.56..2.18 rows=1 width=30) (actual time=0.006..0.007 rows=1 loops=67)

  • Index Cond: ((charge_id)::text = (bac.charge_id)::text)
59. 0.469 0.469 ↑ 1.0 1 67

Index Scan using bill_pkey on bill b (cost=0.56..1.59 rows=1 width=16) (actual time=0.007..0.007 rows=1 loops=67)

  • Index Cond: ((bill_no)::text = (bc.bill_no)::text)
60. 0.017 0.149 ↑ 1.0 49 1

Hash (cost=100.49..100.49 rows=49 width=19) (actual time=0.149..0.149 rows=49 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 3kB
61. 0.132 0.132 ↑ 1.0 49 1

Seq Scan on sample_type st (cost=0.00..100.49 rows=49 width=19) (actual time=0.004..0.132 rows=49 loops=1)