explain.depesz.com

PostgreSQL's explain analyze made readable

Result: opTi

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

Gather (cost=1,542.18..11,248.98 rows=299 width=1,912) (actual time=9.238..336.429 rows=13,864 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
2. 4.221 158.617 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=542.18..6,076.81 rows=176 width=947) (actual time=5.558..158.617 rows=6,932 loops=2)

3. 4.054 154.396 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=541.90..6,023.81 rows=176 width=907) (actual time=5.551..154.396 rows=6,932 loops=2)

4. 4.379 150.342 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=541.62..5,971.05 rows=176 width=872) (actual time=5.546..150.342 rows=6,932 loops=2)

5. 5.057 145.963 ↓ 39.4 6,932 2 / 2

Nested Loop Left Join (cost=541.34..5,918.06 rows=176 width=832) (actual time=5.538..145.963 rows=6,932 loops=2)

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

Hash Left Join (cost=540.93..5,838.50 rows=176 width=838) (actual time=5.522..133.974 rows=6,932 loops=2)

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

Hash Left Join (cost=300.73..5,596.97 rows=176 width=798) (actual time=4.701..130.366 rows=6,932 loops=2)

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

Nested Loop Left Join (cost=51.53..5,344.24 rows=176 width=794) (actual time=1.931..124.287 rows=6,932 loops=2)

9. 3.182 109.513 ↓ 39.4 6,932 2 / 2

Hash Join (cost=51.24..5,171.73 rows=176 width=792) (actual time=1.904..109.513 rows=6,932 loops=2)

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

Hash Join (cost=27.47..5,147.49 rows=176 width=778) (actual time=1.360..105.921 rows=6,932 loops=2)

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

Hash Join (cost=10.84..5,130.39 rows=176 width=757) (actual time=1.010..102.498 rows=6,932 loops=2)

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

Nested Loop (cost=2.41..5,119.54 rows=176 width=190) (actual time=0.277..97.521 rows=6,932 loops=2)

13. 5.099 79.584 ↓ 39.4 6,932 2 / 2

Nested Loop (cost=2.12..5,066.61 rows=176 width=148) (actual time=0.254..79.584 rows=6,932 loops=2)

14. 3.448 60.275 ↓ 37.4 3,553 2 / 2

Nested Loop (cost=1.70..5,008.14 rows=95 width=130) (actual time=0.224..60.275 rows=3,553 loops=2)

15. 3.924 49.722 ↓ 37.4 3,553 2 / 2

Nested Loop (cost=1.42..4,979.79 rows=95 width=74) (actual time=0.193..49.722 rows=3,553 loops=2)

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

Nested Loop (cost=1.13..4,944.85 rows=106 width=58) (actual time=0.163..38.593 rows=3,603 loops=2)

17. 2.453 21.634 ↓ 1.1 3,603 2 / 2

Nested Loop (cost=0.71..3,274.78 rows=3,358 width=42) (actual time=0.134..21.634 rows=3,603 loops=2)

18. 0.576 12.209 ↓ 1.1 1,162 2 / 2

Nested Loop (cost=0.29..2,592.75 rows=1,017 width=30) (actual time=0.105..12.209 rows=1,162 loops=2)

19. 8.056 8.056 ↓ 1.1 716 2 / 2

Parallel Seq Scan on work_orders w (cost=0.00..1,590.60 rows=656 width=22) (actual time=0.069..8.056 rows=716 loops=2)

  • Filter: (active AND (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))
  • Rows Removed by Filter: 15,547
20. 3.578 3.578 ↑ 1.0 2 1,431 / 2

Index Scan using index_samples_on_work_order_id_and_position on samples s (cost=0.29..1.51 rows=2 width=12) (actual time=0.004..0.005 rows=2 loops=1,431)

  • Index Cond: (work_order_id = w.id)
21. 6.972 6.972 ↑ 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.004..0.006 rows=3 loops=2,324)

  • Index Cond: (sample_id = s.id)
22. 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))
23. 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
24. 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)
25. 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.003..0.004 rows=2 loops=7,105)

  • Index Cond: (sample_parameter_id = sp.id)
26. 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)
27. 0.035 0.718 ↑ 1.0 82 2 / 2

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 19kB
28. 0.039 0.683 ↑ 1.0 82 2 / 2

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

  • Hash Cond: (fsd.functional_structure_id = fs.id)
29. 0.040 0.428 ↑ 1.0 82 2 / 2

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

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

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

31. 0.006 0.190 ↑ 1.0 9 2 / 2

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

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

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

33. 0.027 0.216 ↑ 1.0 82 2 / 2

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 16kB
34. 0.189 0.189 ↑ 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.189 rows=82 loops=2)

35. 0.066 0.337 ↑ 1.0 339 2 / 2

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

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

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

37. 0.087 0.410 ↑ 1.0 390 2 / 2

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

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

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

39. 6.932 6.932 ↑ 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.001..0.001 rows=1 loops=13,864)

  • Index Cond: (id = w.patient_id)
40. 1.342 2.720 ↑ 1.0 7,248 2 / 2

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

  • Buckets: 8,192 Batches: 1 Memory Usage: 376kB
41. 1.378 1.378 ↑ 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.178..1.378 rows=7,248 loops=2)

42. 0.001 0.810 ↓ 0.0 0 2 / 2

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
43. 0.000 0.809 ↓ 0.0 0 2 / 2

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

44. 0.809 0.809 ↓ 0.0 0 2 / 2

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

  • Filter: ((report_note_definition_id = 3) AND ((commentable_type)::text = 'SampleRegistration'::text))
  • Rows Removed by Filter: 2,818
45. 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)
46. 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)
47. 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)
48. 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)
49. 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)
50.          

SubPlan (for Gather)

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

52. 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
53. 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
54. 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)

55. 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
56. 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
57. 13.842 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)

58. 0.000 27.684 ↓ 0.0 0 13,842

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

  • Sort Key: report_requisicao.created_at
  • Sort Method: quicksort Memory: 25kB
59. 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
60. 0.000 97.048 ↑ 1.0 1 13,864

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

61. 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
62. 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