explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Cr6R

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 7,844.720 ↑ 1.0 20 1

Limit (cost=1,664,685.09..1,664,706.79 rows=20 width=602) (actual time=7,844.533..7,844.720 rows=20 loops=1)

2. 0.218 7,844.716 ↑ 13.3 21 1

GroupAggregate (cost=1,664,684.00..1,664,986.72 rows=279 width=602) (actual time=7,844.523..7,844.716 rows=21 loops=1)

3. 0.172 7,844.498 ↑ 10.3 27 1

Sort (cost=1,664,684.00..1,664,684.70 rows=279 width=602) (actual time=7,844.497..7,844.498 rows=27 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: 48kB
4. 0.013 7,844.326 ↑ 4.2 67 1

Subquery Scan on foo (cost=620,214.91..1,664,672.67 rows=279 width=602) (actual time=7,801.283..7,844.326 rows=67 loops=1)

5. 2.927 7,844.313 ↑ 4.2 67 1

Hash Join (cost=620,214.91..1,664,669.88 rows=279 width=366) (actual time=7,801.282..7,844.313 rows=67 loops=1)

  • Hash Cond: (sc.sample_type_id = st.sample_type_id)
6. 0.016 7,841.253 ↑ 4.2 67 1

Nested Loop (cost=620,113.81..1,664,424.04 rows=279 width=351) (actual time=7,800.981..7,841.253 rows=67 loops=1)

7. 0.061 7,840.768 ↑ 4.2 67 1

Nested Loop (cost=620,113.25..1,663,976.87 rows=279 width=363) (actual time=7,800.964..7,840.768 rows=67 loops=1)

8. 0.037 7,840.305 ↑ 4.2 67 1

Nested Loop Left Join (cost=620,112.69..1,663,367.18 rows=279 width=353) (actual time=7,800.950..7,840.305 rows=67 loops=1)

9. 0.046 7,840.268 ↑ 4.2 67 1

Nested Loop Left Join (cost=620,112.26..1,662,993.79 rows=279 width=348) (actual time=7,800.947..7,840.268 rows=67 loops=1)

10. 0.036 7,840.222 ↑ 4.2 67 1

Hash Left Join (cost=620,111.83..1,662,372.03 rows=279 width=348) (actual time=7,800.943..7,840.222 rows=67 loops=1)

  • Hash Cond: (pr.collection_center_id = scc.collection_center_id)
11. 0.018 7,840.184 ↑ 4.2 67 1

Nested Loop (cost=620,110.80..1,662,367.17 rows=279 width=339) (actual time=7,800.933..7,840.184 rows=67 loops=1)

12. 0.033 7,839.764 ↑ 4.5 67 1

Hash Left Join (cost=620,110.36..1,661,617.32 rows=299 width=337) (actual time=7,800.916..7,839.764 rows=67 loops=1)

  • Hash Cond: ((isr.orig_lab_name)::text = (ih.hospital_id)::text)
13. 0.004 7,839.723 ↑ 4.5 67 1

Nested Loop Left Join (cost=620,108.95..1,661,611.81 rows=299 width=334) (actual time=7,800.903..7,839.723 rows=67 loops=1)

  • Join Filter: ((isr.incoming_visit_id)::text = (isrd.incoming_visit_id)::text)
14. 0.047 7,839.585 ↑ 4.5 67 1

Hash Left Join (cost=620,108.53..1,661,227.76 rows=299 width=317) (actual time=7,800.894..7,839.585 rows=67 loops=1)

  • Hash Cond: ((pd.salutation)::text = (sm.salutation_id)::text)
15. 0.032 7,839.528 ↑ 4.5 67 1

Nested Loop Left Join (cost=620,107.05..1,661,222.17 rows=299 width=321) (actual time=7,800.870..7,839.528 rows=67 loops=1)

16. 0.046 7,838.960 ↑ 4.5 67 1

Hash Join (cost=620,106.62..1,660,809.76 rows=299 width=288) (actual time=7,800.851..7,838.960 rows=67 loops=1)

  • Hash Cond: ((d.ddept_id)::text = (diagnostics_departments.ddept_id)::text)
17. 0.371 7,838.906 ↑ 4.5 67 1

Hash Left Join (cost=620,105.35..1,660,804.37 rows=299 width=275) (actual time=7,800.835..7,838.906 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
18. 0.431 7,748.273 ↑ 151.9 394 1

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

19. 0.229 7,745.872 ↑ 151.9 394 1

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

  • Hash Cond: ((COALESCE(tp.test_id, tpr.test_id))::text = (d.test_id)::text)
20. 1,450.751 7,744.387 ↑ 151.9 394 1

Merge Right Join (cost=610,168.06..1,368,018.52 rows=59,833 width=154) (actual time=7,706.344..7,744.387 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
21. 2,443.532 2,443.532 ↑ 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..2,443.532 rows=6,466,843 loops=1)

22. 0.210 3,850.104 ↑ 284.3 466 1

Sort (cost=610,167.63..610,498.89 rows=132,504 width=145) (actual time=3,850.047..3,850.104 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
23. 518.897 3,849.894 ↑ 515.6 257 1

Hash Left Join (cost=550,887.81..598,894.40 rows=132,504 width=145) (actual time=3,329.558..3,849.894 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)
24. 0.735 599.853 ↑ 515.6 257 1

Hash Left Join (cost=143,117.19..144,767.40 rows=132,504 width=130) (actual time=598.121..599.853 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
25. 3.389 599.014 ↑ 36.3 4,148 1

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

  • Hash Cond: (sr.sample_collection_id = sc.sample_collection_id)
26. 1.300 1.300 ↑ 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.300 rows=25,665 loops=1)

27. 1.150 594.325 ↑ 36.3 4,148 1

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

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

Seq Scan on sample_collection sc (cost=0.00..141,225.46 rows=150,471 width=101) (actual time=370.427..593.175 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
29. 0.011 0.104 ↑ 1.0 67 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 4kB
30. 0.020 0.093 ↑ 1.0 67 1

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

  • Hash Cond: ((dom.outsource_dest)::text = (hcm.center_id)::text)
31. 0.022 0.056 ↑ 1.0 67 1

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

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

33. 0.012 0.028 ↑ 1.0 59 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 4kB
34. 0.016 0.016 ↑ 1.0 59 1

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

35. 0.007 0.017 ↑ 1.0 23 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
36. 0.010 0.010 ↑ 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.010 rows=23 loops=1)

37. 1,313.483 2,731.144 ↓ 1.0 7,554,345 1

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

  • Buckets: 131072 Batches: 8 Memory Usage: 46133kB
38. 1,417.661 1,417.661 ↓ 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.002..1,417.661 rows=7,554,345 loops=1)

39. 0.423 1.256 ↑ 1.0 1,798 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 143kB
40. 0.833 0.833 ↑ 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.833 rows=1,798 loops=1)

41. 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)
42. 44.455 90.262 ↑ 1.0 225,307 1

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

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

44. 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
45. 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)

46. 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)
47. 0.006 0.010 ↑ 1.0 21 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 1kB
48. 0.004 0.004 ↑ 1.0 21 1

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

49. 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)
50. 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
51. 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)

52. 0.402 0.402 ↑ 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.006..0.006 rows=1 loops=67)

  • Index Cond: (COALESCE((tp.prescribed_id)::text, (tpr.prescribed_id)::text) = (activity_id)::text)
  • Filter: ((activity_code)::text = 'DIA'::text)
53. 0.001 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
54. 0.001 0.001 ↑ 1.0 1 1

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

55. 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)
56. 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)
57. 0.402 0.402 ↑ 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.006 rows=1 loops=67)

  • Index Cond: ((charge_id)::text = (bac.charge_id)::text)
58. 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.006..0.007 rows=1 loops=67)

  • Index Cond: ((bill_no)::text = (bc.bill_no)::text)
59. 0.013 0.133 ↑ 1.0 49 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 3kB
60. 0.120 0.120 ↑ 1.0 49 1

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