explain.depesz.com

PostgreSQL's explain analyze made readable

Result: jNLr

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 1,151.880 ↓ 30.5 43,818 1

Gather (cost=7,881.12..33,743.60 rows=1,435 width=1,912) (actual time=86.178..1,151.880 rows=43,818 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
2. 7.175 483.822 ↓ 26.0 21,909 2 / 2

Hash Left Join (cost=6,881.12..12,719.95 rows=844 width=947) (actual time=53.224..483.822 rows=21,909 loops=2)

  • Hash Cond: (spa.interpretation_notes_pre_defined_text_id = pdtip.id)
3. 7.523 475.767 ↓ 26.0 21,909 2 / 2

Hash Left Join (cost=6,690.92..12,527.53 rows=844 width=907) (actual time=52.328..475.767 rows=21,909 loops=2)

  • Hash Cond: (spa.clinical_information_pre_defined_text_id = pdticp.id)
4. 15.081 467.093 ↓ 26.0 21,909 2 / 2

Nested Loop Left Join (cost=6,509.36..12,343.75 rows=844 width=867) (actual time=51.163..467.093 rows=21,909 loops=2)

5. 26.277 452.012 ↓ 26.0 21,909 2 / 2

Nested Loop Left Join (cost=6,509.08..12,090.80 rows=844 width=832) (actual time=51.154..452.012 rows=21,909 loops=2)

  • Join Filter: ((ar.type)::text = 'text'::text)
6. 7.824 403.826 ↓ 26.0 21,909 2 / 2

Hash Left Join (cost=6,508.66..11,709.28 rows=844 width=838) (actual time=51.121..403.826 rows=21,909 loops=2)

  • Hash Cond: (sr.id = ica.commentable_id)
7. 11.881 395.210 ↓ 26.0 21,909 2 / 2

Hash Left Join (cost=6,268.46..11,462.75 rows=844 width=798) (actual time=50.315..395.210 rows=21,909 loops=2)

  • Hash Cond: ((w.id = rtl.work_order_id) AND (sp.id = rtl.sample_parameter_id))
8. 26.545 380.376 ↓ 26.0 21,902 2 / 2

Nested Loop Left Join (cost=6,019.26..11,196.66 rows=844 width=794) (actual time=47.307..380.376 rows=21,902 loops=2)

9. 10.226 331.929 ↓ 26.0 21,902 2 / 2

Hash Join (cost=6,018.97..10,810.47 rows=844 width=792) (actual time=47.284..331.929 rows=21,902 loops=2)

  • Hash Cond: (w.created_by_id = u.id)
10. 11.529 321.287 ↓ 26.0 21,902 2 / 2

Hash Join (cost=5,995.20..10,784.46 rows=844 width=778) (actual time=46.763..321.287 rows=21,902 loops=2)

  • Hash Cond: (sr.lab_matrix_id = lm.id)
11. 13.207 309.400 ↓ 26.0 21,902 2 / 2

Hash Join (cost=5,978.57..10,765.60 rows=844 width=757) (actual time=46.395..309.400 rows=21,902 loops=2)

  • Hash Cond: (sp.functional_structure_id = fsd.functional_structure_id)
12. 12.631 295.509 ↓ 26.0 21,902 2 / 2

Nested Loop (cost=5,970.14..10,745.56 rows=844 width=190) (actual time=45.700..295.509 rows=21,902 loops=2)

13. 15.167 239.074 ↓ 26.0 21,902 2 / 2

Nested Loop (cost=5,969.86..10,491.75 rows=844 width=148) (actual time=45.678..239.074 rows=21,902 loops=2)

14. 11.693 174.837 ↓ 26.9 12,268 2 / 2

Nested Loop (cost=5,969.43..10,211.11 rows=456 width=130) (actual time=45.637..174.837 rows=12,268 loops=2)

15. 4.179 138.609 ↓ 26.9 12,268 2 / 2

Nested Loop (cost=5,969.15..10,075.00 rows=456 width=74) (actual time=45.621..138.609 rows=12,268 loops=2)

  • Join Filter: (s.registration_id = sr.id)
16. 34.873 97.106 ↓ 24.4 12,442 2 / 2

Parallel Hash Join (cost=5,968.86..9,907.25 rows=509 width=58) (actual time=45.594..97.106 rows=12,442 loops=2)

  • Hash Cond: ((spa.sample_registration_id = s.registration_id) AND (spa.analytical_parameter_id = sp.parameter_id))
17. 17.095 17.095 ↑ 1.2 86,494 2 / 2

Parallel Seq Scan on sample_parameter_assignments spa (cost=0.00..3,172.37 rows=101,737 width=16) (actual time=0.013..17.095 rows=86,494 loops=2)

18. 6.293 45.138 ↑ 1.3 12,442 2 / 2

Parallel Hash (cost=5,726.91..5,726.91 rows=16,130 width=42) (actual time=45.138..45.138 rows=12,442 loops=2)

  • Buckets: 32,768 Batches: 1 Memory Usage: 2,240kB
19. 3.445 38.845 ↑ 1.3 12,442 2 / 2

Nested Loop (cost=856.38..5,726.91 rows=16,130 width=42) (actual time=10.749..38.845 rows=12,442 loops=2)

20. 5.906 19.914 ↑ 1.3 3,872 2 / 2

Hash Join (cost=855.96..2,450.92 rows=4,885 width=30) (actual time=10.714..19.914 rows=3,872 loops=2)

  • Hash Cond: (s.work_order_id = w.id)
21. 3.377 3.377 ↑ 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.012..3.377 rows=25,124 loops=2)

22. 1.398 10.631 ↓ 1.0 5,455 2 / 2

Hash (cost=789.08..789.08 rows=5,350 width=22) (actual time=10.631..10.631 rows=5,455 loops=2)

  • Buckets: 8,192 Batches: 1 Memory Usage: 359kB
23. 9.233 9.233 ↓ 1.0 5,455 2 / 2

Index Scan using idx_received_at on work_orders w (cost=0.29..789.08 rows=5,350 width=22) (actual time=0.049..9.233 rows=5,455 loops=2)

  • Index Cond: ((received_at >= '2019-12-31 23:59:59'::timestamp without time zone) AND (received_at <= '2020-01-31 23:59:59'::timestamp without time zone))
  • Filter: active
  • Rows Removed by Filter: 55
24. 15.486 15.486 ↑ 2.0 3 7,743 / 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.003..0.004 rows=3 loops=7,743)

  • Index Cond: (sample_id = s.id)
25. 37.325 37.325 ↑ 1.0 1 24,883 / 2

Index Scan using sample_registrations_pkey on sample_registrations sr (cost=0.29..0.32 rows=1 width=28) (actual time=0.003..0.003 rows=1 loops=24,883)

  • Index Cond: (id = spa.sample_registration_id)
  • Filter: active
  • Rows Removed by Filter: 0
26. 24.535 24.535 ↑ 1.0 1 24,535 / 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=24,535)

  • Index Cond: (id = spa.analytical_parameter_id)
27. 49.070 49.070 ↑ 2.5 2 24,535 / 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=24,535)

  • Index Cond: (sample_parameter_id = sp.id)
28. 43.804 43.804 ↑ 1.0 1 43,804 / 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=43,804)

  • Index Cond: (id = ar.definition_id)
29. 0.025 0.684 ↑ 1.0 82 2 / 2

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 19kB
30. 0.053 0.659 ↑ 1.0 82 2 / 2

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

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

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

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

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

33. 0.008 0.184 ↑ 1.0 9 2 / 2

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

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

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

35. 0.018 0.207 ↑ 1.0 82 2 / 2

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

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

37. 0.066 0.358 ↑ 1.0 339 2 / 2

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

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

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

39. 0.088 0.416 ↑ 1.0 390 2 / 2

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

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

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

41. 21.902 21.902 ↑ 1.0 1 43,804 / 2

Index Scan using patients_pk on patients p (cost=0.29..0.46 rows=1 width=10) (actual time=0.001..0.001 rows=1 loops=43,804)

  • Index Cond: (id = w.patient_id)
42. 1.433 2.953 ↑ 1.0 7,248 2 / 2

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

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

44. 0.001 0.792 ↓ 0.0 0 2 / 2

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

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

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

46. 0.791 0.791 ↓ 0.0 0 2 / 2

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

  • Filter: ((report_note_definition_id = 3) AND ((commentable_type)::text = 'SampleRegistration'::text))
  • Rows Removed by Filter: 2,818
47. 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)
48. 21.909 21.909 ↓ 0.0 0 43,818 / 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=43,818)

  • Index Cond: (id = ar.value_id)
49. 0.000 0.000 ↓ 0.0 0 43,818 / 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=43,818)

  • Index Cond: (id = trv.text_result_pre_defined_text_id)
50. 0.151 1.151 ↑ 1.0 718 2 / 2

Hash (cost=172.59..172.59 rows=718 width=48) (actual time=1.151..1.151 rows=718 loops=2)

  • Buckets: 1,024 Batches: 1 Memory Usage: 70kB
51. 1.000 1.000 ↑ 1.0 718 2 / 2

Seq Scan on pre_defined_texts pdticp (cost=0.00..172.59 rows=718 width=48) (actual time=0.190..1.000 rows=718 loops=2)

  • Filter: ((master_type)::text = 'comment'::text)
  • Rows Removed by Filter: 1,409
52. 0.298 0.880 ↑ 1.0 1,409 2 / 2

Hash (cost=172.59..172.59 rows=1,409 width=48) (actual time=0.880..0.880 rows=1,409 loops=2)

  • Buckets: 2,048 Batches: 1 Memory Usage: 126kB
53. 0.582 0.582 ↑ 1.0 1,409 2 / 2

Seq Scan on pre_defined_texts pdtip (cost=0.00..172.59 rows=1,409 width=48) (actual time=0.008..0.582 rows=1,409 loops=2)

  • Filter: ((master_type)::text = 'interpretation'::text)
  • Rows Removed by Filter: 718
54.          

SubPlan (for Gather)

55. 0.000 219.090 ↓ 0.0 0 43,818

Limit (cost=3.77..3.78 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=43,818)

56. 43.818 219.090 ↓ 0.0 0 43,818

Sort (cost=3.77..3.78 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=43,818)

  • Sort Key: report_parametro.created_at
  • Sort Method: quicksort Memory: 25kB
57. 175.272 175.272 ↓ 0.0 0 43,818

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.004..0.004 rows=0 loops=43,818)

  • 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: 2
58. 0.000 219.090 ↓ 0.0 0 43,818

Limit (cost=3.77..3.77 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=43,818)

59. 43.818 219.090 ↓ 0.0 0 43,818

Sort (cost=3.77..3.77 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=43,818)

  • Sort Key: report_amostra.created_at
  • Sort Method: quicksort Memory: 25kB
60. 175.272 175.272 ↓ 0.0 0 43,818

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.003..0.004 rows=0 loops=43,818)

  • 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: 2
61. 34.104 136.416 ↓ 0.0 0 34,104

Limit (cost=3.76..3.77 rows=1 width=8) (actual time=0.004..0.004 rows=0 loops=34,104)

62. 0.000 102.312 ↓ 0.0 0 34,104

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

  • Sort Key: report_requisicao.created_at
  • Sort Method: quicksort Memory: 25kB
63. 102.312 102.312 ↓ 0.0 0 34,104

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.003..0.003 rows=0 loops=34,104)

  • 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: 1
64. 0.000 306.726 ↑ 1.0 1 43,818

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

65. 43.818 306.726 ↑ 1.0 1 43,818

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

  • Sort Key: technical_parameters.lab_matrix_id, technical_parameters.functional_structure_id, technical_parameters.response_time_days
  • Sort Method: quicksort Memory: 25kB
66. 262.908 262.908 ↑ 1.0 1 43,818

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=43,818)

  • 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: 309,621