explain.depesz.com

PostgreSQL's explain analyze made readable

Result: nBly

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 8,972.751 ↓ 3.3 20 1

Limit (cost=1,560,008.66..1,560,015.17 rows=6 width=602) (actual time=8,972.549..8,972.751 rows=20 loops=1)

2. 0.367 8,972.748 ↓ 3.0 21 1

GroupAggregate (cost=1,560,007.58..1,560,015.17 rows=7 width=602) (actual time=8,972.539..8,972.748 rows=21 loops=1)

3. 0.176 8,972.381 ↓ 3.4 24 1

Sort (cost=1,560,007.58..1,560,007.59 rows=7 width=602) (actual time=8,972.379..8,972.381 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.006 8,972.205 ↓ 8.7 61 1

Subquery Scan on foo (cost=1,560,003.80..1,560,007.48 rows=7 width=602) (actual time=8,972.184..8,972.205 rows=61 loops=1)

5. 0.245 8,972.199 ↓ 8.7 61 1

HashAggregate (cost=1,560,003.80..1,560,007.41 rows=7 width=366) (actual time=8,972.182..8,972.199 rows=61 loops=1)

6. 6.008 8,971.954 ↓ 9.6 67 1

Nested Loop (cost=1,000,880.02..1,560,003.16 rows=7 width=366) (actual time=8,319.215..8,971.954 rows=67 loops=1)

7. 0.064 8,965.678 ↓ 9.6 67 1

Nested Loop (cost=1,000,879.75..1,559,990.95 rows=7 width=351) (actual time=8,318.221..8,965.678 rows=67 loops=1)

8. 0.066 8,964.944 ↓ 9.6 67 1

Nested Loop (cost=1,000,879.19..1,559,979.73 rows=7 width=363) (actual time=8,318.200..8,964.944 rows=67 loops=1)

9. 0.129 8,964.275 ↓ 9.6 67 1

Nested Loop (cost=1,000,878.63..1,559,964.43 rows=7 width=353) (actual time=8,318.179..8,964.275 rows=67 loops=1)

10. 0.066 8,963.610 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,878.18..1,559,946.87 rows=7 width=351) (actual time=8,318.153..8,963.610 rows=67 loops=1)

11. 0.069 8,963.544 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,877.75..1,559,937.51 rows=7 width=346) (actual time=8,318.151..8,963.544 rows=67 loops=1)

12. 0.110 8,963.475 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,877.32..1,559,921.91 rows=7 width=346) (actual time=8,318.148..8,963.475 rows=67 loops=1)

  • Join Filter: (scc.collection_center_id = pr.collection_center_id)
13. 0.061 8,963.365 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,877.32..1,559,920.79 rows=7 width=337) (actual time=8,318.134..8,963.365 rows=67 loops=1)

14. 0.062 8,963.304 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,877.18..1,559,919.63 rows=7 width=334) (actual time=8,318.131..8,963.304 rows=67 loops=1)

  • Join Filter: ((isr.incoming_visit_id)::text = (isrd.incoming_visit_id)::text)
15. 0.112 8,963.041 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,876.76..1,559,910.64 rows=7 width=317) (actual time=8,318.123..8,963.041 rows=67 loops=1)

16. 0.084 8,962.795 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,876.62..1,559,909.49 rows=7 width=321) (actual time=8,318.113..8,962.795 rows=67 loops=1)

17. 0.046 8,962.041 ↓ 9.6 67 1

Nested Loop (cost=1,000,876.19..1,559,899.83 rows=7 width=288) (actual time=8,318.090..8,962.041 rows=67 loops=1)

18. 0.330 8,961.794 ↓ 9.6 67 1

Nested Loop Left Join (cost=1,000,876.06..1,559,898.63 rows=7 width=275) (actual time=8,318.080..8,961.794 rows=67 loops=1)

  • Filter: (COALESCE(pr.center_id, isr.center_id) = 13)
  • Rows Removed by Filter: 324
19. 0.501 8,960.682 ↑ 3.4 391 1

Nested Loop Left Join (cost=1,000,875.64..1,558,081.67 rows=1,325 width=228) (actual time=7,654.802..8,960.682 rows=391 loops=1)

20. 0.135 8,957.053 ↑ 3.4 391 1

Hash Left Join (cost=1,000,875.20..1,551,859.25 rows=1,325 width=187) (actual time=7,654.766..8,957.053 rows=391 loops=1)

  • Hash Cond: ((dom.outsource_dest)::text = (hcm.center_id)::text)
21. 0.175 8,956.898 ↑ 3.4 391 1

Hash Left Join (cost=1,000,870.69..1,551,841.90 rows=1,325 width=184) (actual time=7,654.736..8,956.898 rows=391 loops=1)

  • Hash Cond: ((dom.outsource_dest)::text = (om.oh_id)::text)
22. 0.394 8,956.695 ↑ 3.4 391 1

Hash Join (cost=1,000,868.36..1,551,822.93 rows=1,325 width=171) (actual time=7,654.690..8,956.695 rows=391 loops=1)

  • Hash Cond: ((COALESCE(tp.test_id, tpr.test_id))::text = (d.test_id)::text)
23. 639.645 8,954.714 ↑ 3.4 391 1

Hash Left Join (cost=1,000,317.90..1,551,252.60 rows=1,325 width=138) (actual time=7,653.091..8,954.714 rows=391 loops=1)

  • Hash Cond: ((CASE WHEN (sc.sample_status = 'R'::bpchar) THEN sr.test_prescribed_id ELSE sc.sample_collection_id END = tp.sample_collection_id) AND ((sc.mr_no)::text = (tp.mr_no)::text))
  • Filter: ((CASE WHEN (sc.sample_status = 'R'::bpchar) THEN tpr.conducted ELSE tp.conducted END)::text = ANY ('{N,NRN}'::text[]))
  • Rows Removed by Filter: 75
24. 663.302 4,499.787 ↑ 515.6 257 1

Hash Left Join (cost=551,544.10..598,627.92 rows=132,504 width=144) (actual time=3,836.923..4,499.787 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. 2.282 754.907 ↑ 515.6 257 1

Hash Right Join (cost=143,773.48..144,500.92 rows=132,504 width=129) (actual time=754.808..754.907 rows=257 loops=1)

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

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

27. 0.141 751.222 ↑ 515.6 257 1

Hash (cost=142,117.18..142,117.18 rows=132,504 width=125) (actual time=751.222..751.222 rows=257 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 31kB
28. 0.891 751.081 ↑ 515.6 257 1

Hash Left Join (cost=2.51..142,117.18 rows=132,504 width=125) (actual time=668.714..751.081 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
29. 750.167 750.167 ↑ 36.3 4,148 1

Seq Scan on sample_collection sc (cost=0.00..141,225.46 rows=150,471 width=116) (actual time=444.558..750.167 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.012 0.023 ↑ 1.0 67 1

Hash (cost=1.67..1.67 rows=67 width=15) (actual time=0.023..0.023 rows=67 loops=1)

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

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

32. 1,462.449 3,081.578 ↓ 1.0 7,554,334 1

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

  • Buckets: 131072 Batches: 8 Memory Usage: 46133kB
33. 1,619.129 1,619.129 ↓ 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.007..1,619.129 rows=7,554,334 loops=1)

34. 1,650.380 3,815.282 ↑ 1.2 6,466,203 1

Hash (cost=276,500.72..276,500.72 rows=7,551,672 width=34) (actual time=3,815.282..3,815.282 rows=6,466,203 loops=1)

  • Buckets: 131072 Batches: 16 Memory Usage: 26988kB
35. 2,164.902 2,164.902 ↓ 1.0 7,554,334 1

Seq Scan on tests_prescribed tp (cost=0.00..276,500.72 rows=7,551,672 width=34) (actual time=0.003..2,164.902 rows=7,554,334 loops=1)

36. 0.446 1.587 ↑ 1.0 1,798 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 143kB
37. 1.141 1.141 ↑ 1.0 1,798 1

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

38. 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
39. 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.011..0.016 rows=59 loops=1)

40. 0.010 0.020 ↑ 1.0 23 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 2kB
41. 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)

42. 3.128 3.128 ↑ 1.0 1 391

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

  • Index Cond: ((patient_id)::text = (sc.patient_id)::text)
43. 0.782 0.782 ↓ 0.0 0 391

Index Scan using incoming_sample_registration_pkey on incoming_sample_registration isr (cost=0.42..1.36 rows=1 width=62) (actual time=0.002..0.002 rows=0 loops=391)

  • Index Cond: ((sc.patient_id)::text = (incoming_visit_id)::text)
44. 0.201 0.201 ↑ 1.0 1 67

Index Scan using diagnostics_departments_pkey on diagnostics_departments (cost=0.14..0.16 rows=1 width=23) (actual time=0.002..0.003 rows=1 loops=67)

  • Index Cond: ((ddept_id)::text = (d.ddept_id)::text)
45. 0.670 0.670 ↑ 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.010..0.010 rows=1 loops=67)

  • Index Cond: ((mr_no)::text = (pr.mr_no)::text)
46. 0.134 0.134 ↑ 1.0 1 67

Index Scan using salutation_master_pkey on salutation_master sm (cost=0.14..0.16 rows=1 width=14) (actual time=0.002..0.002 rows=1 loops=67)

  • Index Cond: ((salutation_id)::text = (pd.salutation)::text)
47. 0.201 0.201 ↓ 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.003..0.003 rows=0 loops=67)

  • Index Cond: (tp.prescribed_id = prescribed_id)
48. 0.000 0.000 ↓ 0.0 0 67

Index Scan using incoming_hospitals_pkey on incoming_hospitals ih (cost=0.14..0.16 rows=1 width=17) (actual time=0.000..0.000 rows=0 loops=67)

  • Index Cond: ((hospital_id)::text = (isr.orig_lab_name)::text)
49. 0.000 0.000 ↑ 1.0 1 67

Materialize (cost=0.00..1.01 rows=1 width=13) (actual time=0.000..0.000 rows=1 loops=67)

50. 0.007 0.007 ↑ 1.0 1 1

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

51. 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)
52. 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)
53. 0.536 0.536 ↑ 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.008..0.008 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.603 0.603 ↑ 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.009..0.009 rows=1 loops=67)

  • Index Cond: ((charge_id)::text = (bac.charge_id)::text)
55. 0.670 0.670 ↑ 1.0 1 67

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

  • Index Cond: ((bill_no)::text = (bc.bill_no)::text)
56. 0.268 0.268 ↑ 1.0 1 67

Index Scan using sample_type_pkey on sample_type st (cost=0.27..1.23 rows=1 width=19) (actual time=0.003..0.004 rows=1 loops=67)

  • Index Cond: (sample_type_id = sc.sample_type_id)