explain.depesz.com

PostgreSQL's explain analyze made readable

Result: wXFL

Settings
# exclusive inclusive rows x rows loops node
1. 1.181 17,338.049 ↓ 7.2 1,468 1

HashAggregate (cost=18,818.40..18,820.44 rows=204 width=98) (actual time=17,337.736..17,338.049 rows=1,468 loops=1)

  • Group Key: n.id, n.identificacao_usual, n.categoria, CASE WHEN (vw.cobertura_id IS NOT NULL) THEN true ELSE false END, CASE WHEN (vw.cobertura_id IS NOT NULL) THEN vw.cobertura_id ELSE NULL::integer END
2.          

CTE animais_aptos

3. 17,130.601 17,130.601 ↓ 1,028.4 5,142 1

Function Scan on obtenha_animais_estoque_por_contrato_propriedade (cost=0.25..12.75 rows=5 width=4) (actual time=17,126.182..17,130.601 rows=5,142 loops=1)

  • Filter: (propriedade_id = 3144)
  • Rows Removed by Filter: 36360
4.          

CTE novilhas

5. 2.653 17,331.815 ↓ 7.2 1,468 1

HashAggregate (cost=17,031.87..17,033.91 rows=204 width=11) (actual time=17,331.403..17,331.815 rows=1,468 loops=1)

  • Group Key: a.id, a.identificacao_usual, ('novilha'::text)
6. 0.718 17,329.162 ↓ 21.4 4,373 1

Append (cost=48.67..17,030.34 rows=204 width=11) (actual time=3.832..17,329.162 rows=4,373 loops=1)

7. 13.878 150.186 ↓ 17.7 3,570 1

Nested Loop Anti Join (cost=48.67..16,926.73 rows=202 width=11) (actual time=3.832..150.186 rows=3,570 loops=1)

8. 7.828 75.030 ↓ 101.1 20,426 1

Nested Loop (cost=48.11..15,174.89 rows=202 width=11) (actual time=1.281..75.030 rows=20,426 loops=1)

9. 14.535 15.570 ↓ 12.1 3,688 1

Bitmap Heap Scan on mbw_animal a (cost=47.55..7,635.52 rows=306 width=11) (actual time=1.164..15.570 rows=3,688 loops=1)

  • Recheck Cond: (propriedade_id = 3144)
  • Filter: ((data_morte IS NULL) AND ((data_descarte_reprodutor IS NULL) OR (data_descarte_reprodutor < '2018-07-01'::date)) AND (tipo_id <> 4) AND (sexo = 0) AND (((date_part('year'::text, age('2018-07-01 00:00:00'::timestamp without time zone, (data_nascimento)::timestamp without time zone)) * '12'::double precision) + date_part('month'::text, age('2018-07-01 00:00:00'::timestamp without time zone, (data_nascimento)::timestamp without time zone))) > '16'::double precision))
  • Rows Removed by Filter: 4220
  • Heap Blocks: exact=662
10. 1.035 1.035 ↓ 3.9 7,908 1

Bitmap Index Scan on mbw_animal_62d4a177 (cost=0.00..47.48 rows=2,006 width=0) (actual time=1.035..1.035 rows=7,908 loops=1)

  • Index Cond: (propriedade_id = 3144)
11. 51.632 51.632 ↓ 1.5 6 3,688

Index Scan using vw_modelo_reprodutivo_data_hora_cobertura_idx on vw_modelo_reprodutivo cb (cost=0.56..24.60 rows=4 width=4) (actual time=0.005..0.014 rows=6 loops=3,688)

  • Index Cond: ((femea_id = a.id) AND (data_hora_cobertura < '2018-07-01 00:00:00-03'::timestamp with time zone))
  • Filter: (cobertura_situacao_nome <> ALL ('{Servida,Gestante}'::text[]))
  • Rows Removed by Filter: 0
12. 61.278 61.278 ↑ 1.0 1 20,426

Index Scan using vw_modelo_reprodutivo_data_hora_cobertura_idx on vw_modelo_reprodutivo m (cost=0.56..8.63 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=20,426)

  • Index Cond: ((femea_id = a.id) AND (data_hora_cobertura < '2018-07-01 00:00:00-03'::timestamp with time zone) AND (propriedade_id = 3144))
  • Filter: ((data_parto IS NOT NULL) AND (situacao_cria = ANY ('{Vivo,Descartado}'::text[])))
13. 1.331 17,164.915 ↓ 757.0 757 1

Nested Loop Anti Join (cost=0.99..50.28 rows=1 width=11) (actual time=17,126.255..17,164.915 rows=757 loops=1)

14. 4.481 17,152.073 ↓ 3,837.0 3,837 1

Nested Loop (cost=0.43..42.55 rows=1 width=11) (actual time=17,126.236..17,152.073 rows=3,837 loops=1)

15. 17,132.166 17,132.166 ↓ 1,028.4 5,142 1

CTE Scan on animais_aptos apt (cost=0.00..0.10 rows=5 width=4) (actual time=17,126.187..17,132.166 rows=5,142 loops=1)

16. 15.426 15.426 ↑ 1.0 1 5,142

Index Scan using mbw_animal_pkey on mbw_animal a_1 (cost=0.43..8.48 rows=1 width=11) (actual time=0.003..0.003 rows=1 loops=5,142)

  • Index Cond: (id = apt.id_animal)
  • Filter: ((tipo_id <> 4) AND (contrato_id = 16) AND (sexo = 0) AND (((date_part('year'::text, age('2018-07-01 00:00:00'::timestamp without time zone, (data_nascimento)::timestamp without time zone)) * '12'::double precision) + date_part('month'::text, age('2018-07-01 00:00:00'::timestamp without time zone, (data_nascimento)::timestamp without time zone))) > '16'::double precision))
  • Rows Removed by Filter: 0
17. 11.511 11.511 ↑ 1.0 1 3,837

Index Only Scan using vw_modelo_reprodutivo_data_hora_cobertura_idx on vw_modelo_reprodutivo (cost=0.56..4.14 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=3,837)

  • Index Cond: ((femea_id = a_1.id) AND (data_hora_cobertura < '2018-07-01 00:00:00-03'::timestamp with time zone) AND (propriedade_id = 3144) AND (contrato_id = 16))
  • Heap Fetches: 0
18. 0.196 13.343 ↓ 46.0 46 1

Nested Loop Anti Join (cost=0.99..51.29 rows=1 width=11) (actual time=11.376..13.343 rows=46 loops=1)

19. 1.121 12.231 ↓ 229.0 229 1

Nested Loop (cost=0.43..42.56 rows=1 width=11) (actual time=0.094..12.231 rows=229 loops=1)

20. 0.826 0.826 ↓ 1,028.4 5,142 1

CTE Scan on animais_aptos apt_1 (cost=0.00..0.10 rows=5 width=4) (actual time=0.001..0.826 rows=5,142 loops=1)

21. 10.284 10.284 ↓ 0.0 0 5,142

Index Scan using mbw_animal_pkey on mbw_animal a_2 (cost=0.43..8.48 rows=1 width=11) (actual time=0.002..0.002 rows=0 loops=5,142)

  • Index Cond: (id = apt_1.id_animal)
  • Filter: ((data_descarte_reprodutor >= '2018-07-01'::date) AND (contrato_id = 16) AND (sexo = 0) AND (tipo_id = 4) AND (((date_part('year'::text, age('2018-07-01 00:00:00'::timestamp without time zone, (data_nascimento)::timestamp without time zone)) * '12'::double precision) + date_part('month'::text, age('2018-07-01 00:00:00'::timestamp without time zone, (data_nascimento)::timestamp without time zone))) > '16'::double precision))
  • Rows Removed by Filter: 1
22. 0.916 0.916 ↑ 1.0 1 229

Index Only Scan using vw_modelo_reprodutivo_data_hora_cobertura_idx on vw_modelo_reprodutivo vw_modelo_reprodutivo_1 (cost=0.56..4.64 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=229)

  • Index Cond: ((femea_id = a_2.id) AND (data_hora_cobertura < '2018-07-01 00:00:00-03'::timestamp with time zone) AND (propriedade_id = 3144) AND (contrato_id = 16))
  • Heap Fetches: 0
23. 1.417 17,336.868 ↓ 7.2 1,468 1

Nested Loop Left Join (cost=0.56..1,769.19 rows=204 width=98) (actual time=17,331.415..17,336.868 rows=1,468 loops=1)

24. 17,332.515 17,332.515 ↓ 7.2 1,468 1

CTE Scan on novilhas n (cost=0.00..4.08 rows=204 width=94) (actual time=17,331.406..17,332.515 rows=1,468 loops=1)

25. 2.936 2.936 ↓ 0.0 0 1,468

Index Scan using vw_modelo_reprodutivo_data_hora_cobertura_idx on vw_modelo_reprodutivo vw (cost=0.56..8.64 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=1,468)

  • Index Cond: ((femea_id = n.id) AND (data_hora_cobertura < '2018-07-01 00:00:00-03'::timestamp with time zone) AND (propriedade_id = 3144) AND (contrato_id = 16))
Planning time : 2.838 ms
Execution time : 17,348.180 ms