explain.depesz.com

PostgreSQL's explain analyze made readable

Result: N7RH

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 358.774 ↓ 46.4 13,864 1

Gather (cost=1,930.64..10,638.43 rows=299 width=1,912) (actual time=11.969..358.774 rows=13,864 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
2. 4.765 168.362 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=930.64..5,466.25 rows=176 width=947) (actual time=8.921..168.362 rows=6,932 loops=2)

3. 4.289 163.597 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=930.36..5,413.26 rows=176 width=907) (actual time=8.914..163.597 rows=6,932 loops=2)

4. 4.879 159.308 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=930.08..5,360.49 rows=176 width=872) (actual time=8.906..159.308 rows=6,932 loops=2)

5. 5.483 154.429 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=929.80..5,307.50 rows=176 width=832) (actual time=8.901..154.429 rows=6,932 loops=2)

  • Join Filter: ((ar.type)::text = 'text'::text)
6. 2.654 142.014 ↓ 39.4 6,932 2 / 2

Hash Left Join (cost=929.39..5,227.94 rows=176 width=838) (actual time=8.888..142.014 rows=6,932 loops=2)

  • Hash Cond: (sr.id = ica.commentable_id)
7. 3.450 138.526 ↓ 39.4 6,932 2 / 2

Hash Left Join (cost=689.19..4,986.41 rows=176 width=798) (actual time=8.038..138.526 rows=6,932 loops=2)

  • Hash Cond: ((w.id = rtl.work_order_id) AND (sp.id = rtl.sample_parameter_id))
8. 2.056 132.442 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=439.99..4,733.68 rows=176 width=794) (actual time=5.374..132.442 rows=6,932 loops=2)

9. 3.348 116.522 ↓ 39.4 6,932 2 / 2

Hash Join (cost=439.70..4,561.02 rows=176 width=792) (actual time=5.351..116.522 rows=6,932 loops=2)

  • Hash Cond: (w.created_by_id = u.id)
10. 3.274 112.760 ↓ 39.4 6,932 2 / 2

Hash Join (cost=415.92..4,536.79 rows=176 width=778) (actual time=4.840..112.760 rows=6,932 loops=2)

  • Hash Cond: (sr.lab_matrix_id = lm.id)
11. 4.537 109.088 ↓ 39.4 6,932 2 / 2

Hash Join (cost=399.30..4,519.69 rows=176 width=757) (actual time=4.432..109.088 rows=6,932 loops=2)

  • Hash Cond: (sp.functional_structure_id = fsd.functional_structure_id)
12. 4.899 103.875 ↓ 39.4 6,932 2 / 2

Nested Loop (cost=390.86..4,508.83 rows=176 width=190) (actual time=3.706..103.875 rows=6,932 loops=2)

13. 5.894 85.112 ↓ 39.4 6,932 2 / 2

Nested Loop (cost=390.58..4,455.91 rows=176 width=148) (actual time=3.680..85.112 rows=6,932 loops=2)

14. 3.804 65.008 ↓ 37.4 3,553 2 / 2

Nested Loop (cost=390.16..4,397.44 rows=95 width=130) (actual time=3.654..65.008 rows=3,553 loops=2)

15. 4.272 54.099 ↓ 37.4 3,553 2 / 2

Nested Loop (cost=389.88..4,369.08 rows=95 width=74) (actual time=3.640..54.099 rows=3,553 loops=2)

  • Join Filter: (s.registration_id = sr.id)
16. 3.629 42.622 ↓ 34.0 3,603 2 / 2

Nested Loop (cost=389.59..4,334.15 rows=106 width=58) (actual time=3.621..42.622 rows=3,603 loops=2)

17. 2.163 24.583 ↓ 1.1 3,603 2 / 2

Nested Loop (cost=389.17..2,665.07 rows=3,356 width=42) (actual time=3.587..24.583 rows=3,603 loops=2)

18. 5.018 14.286 ↓ 1.1 1,162 2 / 2

Hash Join (cost=388.75..1,983.71 rows=1,016 width=30) (actual time=3.551..14.286 rows=1,162 loops=2)

  • Hash Cond: (s.work_order_id = w.id)
19. 5.984 5.984 ↑ 1.2 25,124 2 / 2

Parallel Seq Scan on samples s (cost=0.00..1,516.99 rows=29,699 width=12) (actual time=0.020..5.984 rows=25,124 loops=2)

20. 0.346 3.284 ↓ 1.3 1,431 2 / 2

Hash (cost=374.84..374.84 rows=1,113 width=22) (actual time=3.284..3.284 rows=1,431 loops=2)

  • Buckets: 2,048 Batches: 1 Memory Usage: 94kB
21. 2.938 2.938 ↓ 1.3 1,431 2 / 2

Index Scan using idx_received_at on work_orders w (cost=0.29..374.84 rows=1,113 width=22) (actual time=0.068..2.938 rows=1,431 loops=2)

  • Index Cond: ((received_at >= '2020-02-29 23:59:59'::timestamp without time zone) AND (received_at <= '2020-06-30 23:59:59'::timestamp without time zone))
  • Filter: active
  • Rows Removed by Filter: 18
22. 8.134 8.134 ↑ 2.0 3 2,324 / 2

Index Scan using index_sample_parameters_on_sample_id_and_position on sample_parameters sp (cost=0.42..0.61 rows=6 width=16) (actual time=0.005..0.007 rows=3 loops=2,324)

  • Index Cond: (sample_id = s.id)
23. 14.410 14.410 ↑ 1.0 1 7,205 / 2

Index Scan using index_parameter_assignments_on_parameter_id_and_registration_id on sample_parameter_assignments spa (cost=0.42..0.50 rows=1 width=16) (actual time=0.004..0.004 rows=1 loops=7,205)

  • Index Cond: ((analytical_parameter_id = sp.parameter_id) AND (sample_registration_id = s.registration_id))
24. 7.205 7.205 ↑ 1.0 1 7,205 / 2

Index Scan using sample_registrations_pkey on sample_registrations sr (cost=0.29..0.32 rows=1 width=28) (actual time=0.002..0.002 rows=1 loops=7,205)

  • Index Cond: (id = spa.sample_registration_id)
  • Filter: active
  • Rows Removed by Filter: 0
25. 7.105 7.105 ↑ 1.0 1 7,105 / 2

Index Scan using analytical_parameters_pkey on analytical_parameters ap (cost=0.28..0.30 rows=1 width=64) (actual time=0.002..0.002 rows=1 loops=7,105)

  • Index Cond: (id = spa.analytical_parameter_id)
26. 14.210 14.210 ↑ 2.5 2 7,105 / 2

Index Scan using index_analytical_results_sample_parameter_id on analytical_results ar (cost=0.42..0.57 rows=5 width=22) (actual time=0.004..0.004 rows=2 loops=7,105)

  • Index Cond: (sample_parameter_id = sp.id)
27. 13.864 13.864 ↑ 1.0 1 13,864 / 2

Index Scan using result_definitions_pkey on result_definitions rd (cost=0.28..0.30 rows=1 width=50) (actual time=0.002..0.002 rows=1 loops=13,864)

  • Index Cond: (id = ar.definition_id)
28. 0.032 0.676 ↑ 1.0 82 2 / 2

Hash (cost=7.41..7.41 rows=82 width=575) (actual time=0.676..0.676 rows=82 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 19kB
29. 0.031 0.644 ↑ 1.0 82 2 / 2

Hash Join (cost=5.05..7.41 rows=82 width=575) (actual time=0.600..0.644 rows=82 loops=2)

  • Hash Cond: (fsd.functional_structure_id = fs.id)
30. 0.029 0.404 ↑ 1.0 82 2 / 2

Hash Join (cost=1.20..3.34 rows=82 width=520) (actual time=0.380..0.404 rows=82 loops=2)

  • Hash Cond: (fsd.department_id = d.id)
31. 0.194 0.194 ↑ 1.0 82 2 / 2

Seq Scan on functional_structures_departments fsd (cost=0.00..1.82 rows=82 width=8) (actual time=0.188..0.194 rows=82 loops=2)

32. 0.006 0.181 ↑ 1.0 9 2 / 2

Hash (cost=1.09..1.09 rows=9 width=520) (actual time=0.181..0.181 rows=9 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
33. 0.175 0.175 ↑ 1.0 9 2 / 2

Seq Scan on departments d (cost=0.00..1.09 rows=9 width=520) (actual time=0.172..0.175 rows=9 loops=2)

34. 0.018 0.209 ↑ 1.0 82 2 / 2

Hash (cost=2.82..2.82 rows=82 width=55) (actual time=0.209..0.209 rows=82 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 16kB
35. 0.191 0.191 ↑ 1.0 82 2 / 2

Seq Scan on functional_structures fs (cost=0.00..2.82 rows=82 width=55) (actual time=0.175..0.191 rows=82 loops=2)

36. 0.070 0.398 ↑ 1.0 339 2 / 2

Hash (cost=12.39..12.39 rows=339 width=25) (actual time=0.397..0.398 rows=339 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 28kB
37. 0.328 0.328 ↑ 1.0 339 2 / 2

Seq Scan on lab_matrices lm (cost=0.00..12.39 rows=339 width=25) (actual time=0.212..0.328 rows=339 loops=2)

38. 0.077 0.414 ↑ 1.0 390 2 / 2

Hash (cost=18.90..18.90 rows=390 width=22) (actual time=0.414..0.414 rows=390 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 30kB
39. 0.337 0.337 ↑ 1.0 390 2 / 2

Seq Scan on users u (cost=0.00..18.90 rows=390 width=22) (actual time=0.215..0.337 rows=390 loops=2)

40. 13.864 13.864 ↑ 1.0 1 13,864 / 2

Index Scan using patients_pk on patients p (cost=0.29..0.98 rows=1 width=10) (actual time=0.002..0.002 rows=1 loops=13,864)

  • Index Cond: (id = w.patient_id)
41. 1.246 2.634 ↑ 1.0 7,248 2 / 2

Hash (cost=140.48..140.48 rows=7,248 width=12) (actual time=2.633..2.634 rows=7,248 loops=2)

  • Buckets: 8,192 Batches: 1 Memory Usage: 376kB
42. 1.388 1.388 ↑ 1.0 7,248 2 / 2

Seq Scan on responsability_term_lines rtl (cost=0.00..140.48 rows=7,248 width=12) (actual time=0.205..1.388 rows=7,248 loops=2)

43. 0.001 0.834 ↓ 0.0 0 2 / 2

Hash (cost=239.17..239.17 rows=82 width=48) (actual time=0.834..0.834 rows=0 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
44. 0.001 0.833 ↓ 0.0 0 2 / 2

Nested Loop Left Join (cost=0.28..239.17 rows=82 width=48) (actual time=0.833..0.833 rows=0 loops=2)

45. 0.832 0.832 ↓ 0.0 0 2 / 2

Seq Scan on report_notes ica (cost=0.00..134.27 rows=82 width=8) (actual time=0.832..0.832 rows=0 loops=2)

  • Filter: ((report_note_definition_id = 3) AND ((commentable_type)::text = 'SampleRegistration'::text))
  • Rows Removed by Filter: 2,818
46. 0.000 0.000 ↓ 0.0 0 / 2

Index Scan using pre_defined_texts_pkey on pre_defined_texts pdtica (cost=0.28..1.28 rows=1 width=48) (never executed)

  • Index Cond: (id = ica.pre_defined_text_id)
  • Filter: ((master_type)::text = 'comment'::text)
47. 6.932 6.932 ↓ 0.0 0 13,864 / 2

Index Scan using text_result_values_pkey on text_result_values trv (cost=0.42..0.44 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=13,864)

  • Index Cond: (id = ar.value_id)
48. 0.000 0.000 ↓ 0.0 0 13,864 / 2

Index Scan using pre_defined_texts_pkey on pre_defined_texts pdticp (cost=0.28..0.30 rows=1 width=48) (actual time=0.000..0.000 rows=0 loops=13,864)

  • Index Cond: (id = spa.clinical_information_pre_defined_text_id)
  • Filter: ((master_type)::text = 'comment'::text)
49. 0.000 0.000 ↓ 0.0 0 13,864 / 2

Index Scan using pre_defined_results_pkey on pre_defined_results pdr (cost=0.28..0.30 rows=1 width=43) (actual time=0.000..0.000 rows=0 loops=13,864)

  • Index Cond: (id = trv.text_result_pre_defined_text_id)
50. 0.000 0.000 ↓ 0.0 0 13,864 / 2

Index Scan using pre_defined_texts_pkey on pre_defined_texts pdtip (cost=0.28..0.30 rows=1 width=48) (actual time=0.000..0.000 rows=0 loops=13,864)

  • Index Cond: (id = spa.interpretation_notes_pre_defined_text_id)
  • Filter: ((master_type)::text = 'interpretation'::text)
51.          

SubPlan (for Gather)

52. 0.000 41.592 ↓ 0.0 0 13,864

Limit (cost=3.77..3.78 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=13,864)

53. 13.864 41.592 ↓ 0.0 0 13,864

Sort (cost=3.77..3.78 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=13,864)

  • Sort Key: report_parametro.created_at
  • Sort Method: quicksort Memory: 25kB
54. 27.728 27.728 ↓ 0.0 0 13,864

Index Scan using index_analytical_reports_on_work_order_id_and_preview on analytical_reports report_parametro (cost=0.42..3.76 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=13,864)

  • Index Cond: ((work_order_id = w.id) AND (preview = false))
  • Filter: ((NOT partial) AND (sample_id = s.id) AND (sample_parameter_id = sp.id))
  • Rows Removed by Filter: 0
55. 0.000 41.592 ↓ 0.0 0 13,864

Limit (cost=3.77..3.77 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=13,864)

56. 13.864 41.592 ↓ 0.0 0 13,864

Sort (cost=3.77..3.77 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=13,864)

  • Sort Key: report_amostra.created_at
  • Sort Method: quicksort Memory: 25kB
57. 27.728 27.728 ↓ 0.0 0 13,864

Index Scan using index_analytical_reports_on_work_order_id_and_preview on analytical_reports report_amostra (cost=0.42..3.76 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=13,864)

  • Index Cond: ((work_order_id = w.id) AND (preview = false))
  • Filter: ((sample_parameter_id IS NULL) AND (NOT partial) AND (sample_id = s.id))
  • Rows Removed by Filter: 0
58. 0.000 41.526 ↓ 0.0 0 13,842

Limit (cost=3.76..3.77 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=13,842)

59. 13.842 41.526 ↓ 0.0 0 13,842

Sort (cost=3.76..3.77 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=13,842)

  • Sort Key: report_requisicao.created_at
  • Sort Method: quicksort Memory: 25kB
60. 27.684 27.684 ↓ 0.0 0 13,842

Index Scan using index_analytical_reports_on_work_order_id_and_preview on analytical_reports report_requisicao (cost=0.42..3.75 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=13,842)

  • Index Cond: ((work_order_id = w.id) AND (preview = false))
  • Filter: ((sample_id IS NULL) AND (sample_parameter_id IS NULL) AND (NOT partial))
  • Rows Removed by Filter: 0
61. 13.864 110.912 ↑ 1.0 1 13,864

Limit (cost=2.52..2.52 rows=1 width=12) (actual time=0.008..0.008 rows=1 loops=13,864)

62. 13.864 97.048 ↑ 1.0 1 13,864

Sort (cost=2.52..2.52 rows=1 width=12) (actual time=0.007..0.007 rows=1 loops=13,864)

  • Sort Key: technical_parameters.lab_matrix_id, technical_parameters.functional_structure_id, technical_parameters.response_time_days
  • Sort Method: quicksort Memory: 25kB
63. 83.184 83.184 ↑ 1.0 1 13,864

Index Only Scan using index_technical_params_on_method_param_matrix_and_fstruct_ids on technical_parameters (cost=0.29..2.51 rows=1 width=12) (actual time=0.004..0.006 rows=1 loops=13,864)

  • Index Cond: ((analytical_method_id = ar.analytical_method_id) AND (analytical_parameter_id = sp.parameter_id))
  • Filter: (((lab_matrix_id = sr.lab_matrix_id) OR (lab_matrix_id IS NULL)) AND ((functional_structure_id = sp.functional_structure_id) OR (functional_structure_id IS NULL)))
  • Rows Removed by Filter: 6
  • Heap Fetches: 102,322