explain.depesz.com

PostgreSQL's explain analyze made readable

Result: uY8x

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 10,529.512 ↑ 1.0 20 1

Limit (cost=1,664,855.00..1,664,885.20 rows=20 width=602) (actual time=10,528.876..10,529.512 rows=20 loops=1)

2. 1.027 10,529.508 ↑ 9.5 21 1

GroupAggregate (cost=1,664,853.49..1,665,155.42 rows=200 width=602) (actual time=10,528.846..10,529.508 rows=21 loops=1)

3. 0.408 10,528.481 ↑ 11.6 24 1

Sort (cost=1,664,853.49..1,664,854.19 rows=279 width=602) (actual time=10,528.477..10,528.481 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.030 10,528.073 ↑ 4.6 61 1

Subquery Scan on foo (cost=1,664,695.69..1,664,842.16 rows=279 width=602) (actual time=10,527.985..10,528.073 rows=61 loops=1)

5. 0.501 10,528.043 ↑ 4.6 61 1

HashAggregate (cost=1,664,695.69..1,664,839.37 rows=279 width=366) (actual time=10,527.984..10,528.043 rows=61 loops=1)

6. 137.279 10,527.542 ↑ 4.2 67 1

Hash Join (cost=620,214.91..1,664,669.88 rows=279 width=366) (actual time=10,191.343..10,527.542 rows=67 loops=1)

  • Hash Cond: (sc.sample_type_id = st.sample_type_id)
7. 0.198 10,390.132 ↑ 4.2 67 1

Nested Loop (cost=620,113.81..1,664,424.04 rows=279 width=351) (actual time=10,129.378..10,390.132 rows=67 loops=1)

8. 0.130 10,371.710 ↑ 4.2 67 1

Nested Loop (cost=620,113.25..1,663,976.87 rows=279 width=363) (actual time=10,127.857..10,371.710 rows=67 loops=1)

9. 0.112 10,344.043 ↑ 4.2 67 1

Nested Loop Left Join (cost=620,112.69..1,663,367.18 rows=279 width=353) (actual time=10,127.074..10,344.043 rows=67 loops=1)

10. 0.146 10,343.931 ↑ 4.2 67 1

Nested Loop Left Join (cost=620,112.26..1,662,993.79 rows=279 width=348) (actual time=10,127.071..10,343.931 rows=67 loops=1)

11. 0.113 10,343.785 ↑ 4.2 67 1

Hash Left Join (cost=620,111.83..1,662,372.03 rows=279 width=348) (actual time=10,127.066..10,343.785 rows=67 loops=1)

  • Hash Cond: (pr.collection_center_id = scc.collection_center_id)
12. 0.155 10,343.424 ↑ 4.2 67 1

Nested Loop (cost=620,110.80..1,662,367.17 rows=279 width=339) (actual time=10,126.811..10,343.424 rows=67 loops=1)

13. 0.070 10,324.107 ↑ 4.5 67 1

Hash Left Join (cost=620,110.36..1,661,617.32 rows=299 width=337) (actual time=10,125.530..10,324.107 rows=67 loops=1)

  • Hash Cond: ((isr.orig_lab_name)::text = (ih.hospital_id)::text)
14. 0.136 10,324.029 ↑ 4.5 67 1

Nested Loop Left Join (cost=620,108.95..1,661,611.81 rows=299 width=334) (actual time=10,125.516..10,324.029 rows=67 loops=1)

  • Join Filter: ((isr.incoming_visit_id)::text = (isrd.incoming_visit_id)::text)
15. 0.140 10,321.682 ↑ 4.5 67 1

Hash Left Join (cost=620,108.53..1,661,227.76 rows=299 width=317) (actual time=10,125.232..10,321.682 rows=67 loops=1)

  • Hash Cond: ((pd.salutation)::text = (sm.salutation_id)::text)
16. 0.111 10,321.531 ↑ 4.5 67 1

Nested Loop Left Join (cost=620,107.05..1,661,222.17 rows=299 width=321) (actual time=10,125.206..10,321.531 rows=67 loops=1)

17. 0.103 10,277.535 ↑ 4.5 67 1

Hash Join (cost=620,106.62..1,660,809.76 rows=299 width=288) (actual time=10,124.414..10,277.535 rows=67 loops=1)

  • Hash Cond: ((d.ddept_id)::text = (diagnostics_departments.ddept_id)::text)
18. 0.600 10,277.424 ↑ 4.5 67 1

Hash Left Join (cost=620,105.35..1,660,804.37 rows=299 width=275) (actual time=10,124.395..10,277.424 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.960 10,106.618 ↑ 151.9 394 1

Nested Loop Left Join (cost=610,718.95..1,650,452.12 rows=59,833 width=228) (actual time=9,947.304..10,106.618 rows=394 loops=1)

20. 0.518 10,065.470 ↑ 151.9 394 1

Hash Join (cost=610,718.51..1,369,466.47 rows=59,833 width=187) (actual time=9,946.738..10,065.470 rows=394 loops=1)

  • Hash Cond: ((COALESCE(tp.test_id, tpr.test_id))::text = (d.test_id)::text)
21. 1,507.199 10,063.869 ↑ 151.9 394 1

Merge Right Join (cost=610,168.06..1,368,018.52 rows=59,833 width=154) (actual time=9,945.644..10,063.869 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. 4,620.376 4,620.376 ↑ 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.009..4,620.376 rows=6,466,843 loops=1)

23. 0.274 3,936.294 ↑ 284.3 466 1

Sort (cost=610,167.63..610,498.89 rows=132,504 width=145) (actual time=3,936.196..3,936.294 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. 535.952 3,936.020 ↑ 515.6 257 1

Hash Left Join (cost=550,887.81..598,894.40 rows=132,504 width=145) (actual time=3,398.969..3,936.020 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.732 607.842 ↑ 515.6 257 1

Hash Left Join (cost=143,117.19..144,767.40 rows=132,504 width=130) (actual time=606.168..607.842 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. 3.304 607.002 ↑ 36.3 4,148 1

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

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

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

28. 1.413 602.404 ↑ 36.3 4,148 1

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

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

Seq Scan on sample_collection sc (cost=0.00..141,225.46 rows=150,471 width=101) (actual time=371.290..600.991 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.006 0.108 ↑ 1.0 67 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 4kB
31. 0.022 0.102 ↑ 1.0 67 1

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

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

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

  • Hash Cond: ((dom.outsource_dest)::text = (om.oh_id)::text)
33. 0.005 0.005 ↑ 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.005 rows=67 loops=1)

34. 0.010 0.019 ↑ 1.0 59 1

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

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

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

36. 0.007 0.016 ↑ 1.0 23 1

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

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

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

38. 1,342.480 2,792.226 ↓ 1.0 7,554,334 1

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

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

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

40. 0.414 1.083 ↑ 1.0 1,798 1

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

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

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

42. 40.188 40.188 ↑ 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.102..0.102 rows=1 loops=394)

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

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

  • Buckets: 32768 Batches: 1 Memory Usage: 21046kB
44. 99.738 99.738 ↑ 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..99.738 rows=225,307 loops=1)

45. 0.004 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.004 0.004 ↑ 1.0 12 1

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

47. 43.885 43.885 ↑ 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.654..0.655 rows=1 loops=67)

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

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

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

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

50. 2.211 2.211 ↓ 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.033..0.033 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. 19.162 19.162 ↑ 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.285..0.286 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.002 0.248 ↑ 1.0 1 1

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

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

Seq Scan on sample_collection_centers scc (cost=0.00..1.01 rows=1 width=13) (actual time=0.246..0.246 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. 27.537 27.537 ↑ 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.410..0.411 rows=1 loops=67)

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

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

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

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

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

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