explain.depesz.com

PostgreSQL's explain analyze made readable

Result: k0Fu

Settings
# exclusive inclusive rows x rows loops node
1. 91.487 14,029.551 ↓ 18,074.5 108,447 1

WindowAgg (cost=2,933.37..2,933.61 rows=6 width=126) (actual time=13,914.996..14,029.551 rows=108,447 loops=1)

2.          

CTE animais_consulta

3. 10,902.865 10,902.865 ↓ 4.7 4,720 1

Function Scan on obtenha_animais_estoque_por_propriedade (cost=0.25..10.25 rows=1,000 width=52) (actual time=10,900.504..10,902.865 rows=4,720 loops=1)

4. 130.888 13,938.064 ↓ 18,074.5 108,447 1

Sort (cost=2,923.12..2,923.13 rows=6 width=86) (actual time=13,914.962..13,938.064 rows=108,447 loops=1)

  • Sort Key: c.femea_id, c.data_hora_cobertura, t2.inicio_id
  • Sort Method: external merge Disk: 10760kB
5. 92.962 13,807.176 ↓ 18,074.5 108,447 1

WindowAgg (cost=2,922.83..2,923.04 rows=6 width=86) (actual time=13,687.755..13,807.176 rows=108,447 loops=1)

6. 198.454 13,714.214 ↓ 18,074.5 108,447 1

Sort (cost=2,922.83..2,922.84 rows=6 width=78) (actual time=13,687.730..13,714.214 rows=108,447 loops=1)

  • Sort Key: c.femea_id, c.data_hora_cobertura, (abs((date_part('epoch'::text, c.data_hora_cobertura) - date_part('epoch'::text, (t2.data)::timestamp without time zone))))
  • Sort Method: external merge Disk: 9736kB
7. 160.605 13,515.760 ↓ 18,074.5 108,447 1

Nested Loop (cost=2.85..2,922.75 rows=6 width=78) (actual time=10,900.715..13,515.760 rows=108,447 loops=1)

8. 43.634 13,029.814 ↓ 18,074.5 108,447 1

Nested Loop (cost=2.43..2,915.37 rows=6 width=74) (actual time=10,900.692..13,029.814 rows=108,447 loops=1)

9. 51.976 12,660.839 ↓ 13,555.9 108,447 1

Nested Loop (cost=2.15..2,907.59 rows=8 width=47) (actual time=10,900.676..12,660.839 rows=108,447 loops=1)

10. 47.106 11,172.628 ↓ 2,312.8 20,815 1

Nested Loop (cost=1.58..2,728.72 rows=9 width=31) (actual time=10,900.638..11,172.628 rows=20,815 loops=1)

  • Join Filter: ((a.id = c.femea_id) AND ((c.data_hora_cobertura)::date >= me.data_inicio))
  • Rows Removed by Join Filter: 22230
11. 7.838 11,038.175 ↓ 1,679.8 6,719 1

Nested Loop (cost=1.15..2,714.95 rows=4 width=23) (actual time=10,900.616..11,038.175 rows=6,719 loops=1)

12. 10.573 10,990.023 ↓ 1,679.8 6,719 1

Nested Loop (cost=0.86..2,710.62 rows=4 width=23) (actual time=10,900.601..10,990.023 rows=6,719 loops=1)

13. 6.249 10,946.410 ↓ 196.7 4,720 1

Nested Loop (cost=0.43..2,659.60 rows=24 width=15) (actual time=10,900.581..10,946.410 rows=4,720 loops=1)

14. 10,907.121 10,907.121 ↓ 4.7 4,720 1

CTE Scan on animais_consulta ap (cost=0.00..20.00 rows=1,000 width=4) (actual time=10,900.507..10,907.121 rows=4,720 loops=1)

15. 33.040 33.040 ↑ 1.0 1 4,720

Index Scan using mbw_animal_pkey on mbw_animal a (cost=0.43..2.64 rows=1 width=11) (actual time=0.007..0.007 rows=1 loops=4,720)

  • Index Cond: (id = ap.id)
  • Filter: (contrato_id = 16)
16. 33.040 33.040 ↑ 3.0 1 4,720

Index Scan using mbw_estacaomontaiafemeas_33c37742 on mbw_estacaomontaiafemeas f (cost=0.43..2.10 rows=3 width=8) (actual time=0.005..0.007 rows=1 loops=4,720)

  • Index Cond: (animal_id = a.id)
17. 40.314 40.314 ↑ 1.0 1 6,719

Index Scan using mbw_estacaomontaia_pkey on mbw_estacaomontaia me (cost=0.29..1.08 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=6,719)

  • Index Cond: (id = f.estacao_ia_id)
18. 87.347 87.347 ↑ 1.0 6 6,719

Index Scan using mbw_cobertura_24f7cd40 on mbw_cobertura c (cost=0.43..3.34 rows=6 width=12) (actual time=0.005..0.013 rows=6 loops=6,719)

  • Index Cond: (femea_id = f.animal_id)
19. 1,436.235 1,436.235 ↓ 5.0 5 20,815

Index Scan using mbw_tratamentoanimal_33c37742 on mbw_tratamentoanimal t2 (cost=0.56..19.86 rows=1 width=32) (actual time=0.027..0.069 rows=5 loops=20,815)

  • Index Cond: (animal_id = c.femea_id)
  • Filter: ((data_protocolo IS NOT NULL) AND (data <= c.data_hora_cobertura) AND (data >= ((c.data_hora_cobertura)::date + '-5 days'::interval)))
  • Rows Removed by Filter: 61
20. 325.341 325.341 ↑ 1.0 1 108,447

Index Scan using mbw_protocolo_pkey on mbw_protocolo p (cost=0.28..0.97 rows=1 width=31) (actual time=0.003..0.003 rows=1 loops=108,447)

  • Index Cond: (id = t2.protocolo_id)
  • Filter: (tipo <> 0)
21. 325.341 325.341 ↑ 1.0 1 108,447

Index Only Scan using mbw_material_pkey on mbw_material (cost=0.42..1.22 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=108,447)

  • Index Cond: (id = t2.tratamento_id)
  • Heap Fetches: 108447
Planning time : 27.848 ms
Execution time : 14,045.854 ms