explain.depesz.com

PostgreSQL's explain analyze made readable

Result: R4dZ

Settings
# exclusive inclusive rows x rows loops node
1. 48.334 898.363 ↓ 13,759.0 13,759 1

Sort (cost=9,202.92..9,202.92 rows=1 width=865) (actual time=891.691..898.363 rows=13,759 loops=1)

  • Sort Key: w.created_at DESC, w.number DESC, sp.id DESC
  • Sort Method: external merge Disk: 5,648kB
2. 8.496 850.029 ↓ 13,759.0 13,759 1

Nested Loop Left Join (cost=1,003.81..9,202.91 rows=1 width=865) (actual time=6.701..850.029 rows=13,759 loops=1)

3. 11.280 703.943 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,003.53..9,200.09 rows=1 width=844) (actual time=6.663..703.943 rows=13,759 loops=1)

  • Join Filter: (fsd.functional_structure_id = fs.id)
4. 12.590 678.904 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,003.39..9,199.91 rows=1 width=797) (actual time=6.652..678.904 rows=13,759 loops=1)

5. 127.708 652.555 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,003.25..9,199.71 rows=1 width=285) (actual time=6.636..652.555 rows=13,759 loops=1)

  • Join Filter: (sp.functional_structure_id = fsd.functional_structure_id)
  • Rows Removed by Join Filter: 1,114,479
6. 0.211 0.211 ↑ 1.0 82 1

Index Only Scan using pk_functional_structures_departments on functional_structures_departments fsd (cost=0.14..4.67 rows=82 width=8) (actual time=0.013..0.211 rows=82 loops=1)

  • Heap Fetches: 82
7. 316.993 524.636 ↓ 13,759.0 13,759 82

Materialize (cost=1,003.11..9,193.81 rows=1 width=277) (actual time=0.038..6.398 rows=13,759 loops=82)

8. 9.887 207.643 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,003.11..9,193.81 rows=1 width=277) (actual time=2.405..207.643 rows=13,759 loops=1)

9. 3.269 183.997 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,002.96..9,193.64 rows=1 width=256) (actual time=2.397..183.997 rows=13,759 loops=1)

10. 3.752 153.210 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,002.68..9,193.34 rows=1 width=211) (actual time=2.381..153.210 rows=13,759 loops=1)

11. 1.611 121.940 ↓ 13,759.0 13,759 1

Nested Loop (cost=1,002.40..9,193.04 rows=1 width=169) (actual time=2.372..121.940 rows=13,759 loops=1)

12. 3.379 92.601 ↓ 13,864.0 13,864 1

Nested Loop (cost=1,002.12..9,192.74 rows=1 width=107) (actual time=2.363..92.601 rows=13,864 loops=1)

13. 7.813 61.494 ↓ 13,864.0 13,864 1

Nested Loop (cost=1,001.84..9,192.44 rows=1 width=53) (actual time=2.352..61.494 rows=13,864 loops=1)

14. 0.000 25.527 ↓ 14,077.0 14,077 1

Gather (cost=1,001.55..9,192.10 rows=1 width=45) (actual time=2.341..25.527 rows=14,077 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
15. 5.280 54.628 ↓ 7,039.0 7,039 2 / 2

Nested Loop (cost=1.55..8,192.00 rows=1 width=45) (actual time=0.195..54.628 rows=7,039 loops=2)

16. 2.290 35.271 ↓ 1.1 7,039 2 / 2

Nested Loop (cost=1.13..5,341.47 rows=6,211 width=49) (actual time=0.171..35.271 rows=7,039 loops=2)

17. 1.341 18.571 ↓ 1.1 3,603 2 / 2

Nested Loop (cost=0.71..3,274.78 rows=3,358 width=29) (actual time=0.145..18.571 rows=3,603 loops=2)

18. 0.499 10.258 ↓ 1.1 1,162 2 / 2

Nested Loop (cost=0.29..2,592.75 rows=1,017 width=21) (actual time=0.111..10.258 rows=1,162 loops=2)

19. 6.897 6.897 ↓ 1.1 716 2 / 2

Parallel Seq Scan on work_orders w (cost=0.00..1,590.60 rows=656 width=17) (actual time=0.079..6.897 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. 2.862 2.862 ↑ 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.003..0.004 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 ↑ 2.5 2 7,205 / 2

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

  • Index Cond: (sample_parameter_id = sp.id)
23. 14.077 14.077 ↑ 1.0 1 14,077 / 2

Index Scan using sample_parameter_levels_pkey on sample_parameter_levels spl (cost=0.42..0.45 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=14,077)

  • Index Cond: (id = ar.level_id)
  • Filter: (ar.sample_parameter_id = sample_parameter_id)
24. 28.154 28.154 ↑ 1.0 1 14,077

Index Scan using sample_registrations_pkey on sample_registrations sr (cost=0.29..0.34 rows=1 width=16) (actual time=0.002..0.002 rows=1 loops=14,077)

  • Index Cond: (id = s.registration_id)
  • Filter: active
  • Rows Removed by Filter: 0
25. 27.728 27.728 ↑ 1.0 1 13,864

Index Scan using analytical_parameters_pkey on analytical_parameters ap (cost=0.28..0.30 rows=1 width=58) (actual time=0.002..0.002 rows=1 loops=13,864)

  • Index Cond: (id = sp.parameter_id)
26. 27.728 27.728 ↑ 1.0 1 13,864

Index Scan using analytical_steps_pkey on analytical_steps ans (cost=0.28..0.30 rows=1 width=70) (actual time=0.002..0.002 rows=1 loops=13,864)

  • Index Cond: (id = spl.analytical_step_id)
27. 27.518 27.518 ↑ 1.0 1 13,759

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,759)

  • Index Cond: (id = ar.definition_id)
28. 27.518 27.518 ↑ 1.0 1 13,759

Index Scan using result_definition_suites_pkey on result_definition_suites rds (cost=0.28..0.30 rows=1 width=53) (actual time=0.002..0.002 rows=1 loops=13,759)

  • Index Cond: (id = ar.definition_suite_id)
29. 13.759 13.759 ↑ 1.0 1 13,759

Index Scan using lab_matrices_pkey on lab_matrices lm (cost=0.15..0.17 rows=1 width=25) (actual time=0.001..0.001 rows=1 loops=13,759)

  • Index Cond: (id = sr.lab_matrix_id)
30. 13.759 13.759 ↑ 1.0 1 13,759

Index Scan using departments_pkey on departments d (cost=0.14..0.19 rows=1 width=520) (actual time=0.001..0.001 rows=1 loops=13,759)

  • Index Cond: (id = fsd.department_id)
31. 13.759 13.759 ↑ 1.0 1 13,759

Index Scan using functional_structures_pkey on functional_structures fs (cost=0.14..0.16 rows=1 width=55) (actual time=0.001..0.001 rows=1 loops=13,759)

  • Index Cond: (id = sp.functional_structure_id)
32. 27.518 27.518 ↑ 1.0 1 13,759

Index Scan using analytical_methods_pkey on analytical_methods am (cost=0.28..0.30 rows=1 width=41) (actual time=0.002..0.002 rows=1 loops=13,759)

  • Index Cond: (id = ar.analytical_method_id)
33.          

SubPlan (for Nested Loop Left Join)

34. 13.759 110.072 ↑ 1.0 1 13,759

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

35. 13.759 96.313 ↑ 1.0 1 13,759

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

  • Sort Key: technical_parameters.lab_matrix_id, technical_parameters.functional_structure_id, technical_parameters.response_time_days
  • Sort Method: quicksort Memory: 25kB
36. 82.554 82.554 ↑ 1.0 1 13,759

Index 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,759)

  • 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