explain.depesz.com

PostgreSQL's explain analyze made readable

Result: a2X1

Settings
# exclusive inclusive rows x rows loops node
1. 3.555 17,536.170 ↓ 7.0 1,422 1

HashAggregate (cost=16,993.31..16,995.34 rows=203 width=11) (actual time=17,535.834..17,536.170 rows=1,422 loops=1)

  • Group Key: a.id, a.identificacao_usual, ('novilha'::text)
2.          

CTE animais_aptos

3. 17,292.768 17,292.768 ↓ 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,288.573..17,292.768 rows=5,142 loops=1)

  • Filter: (propriedade_id = 3144)
  • Rows Removed by Filter: 36360
4. 0.942 17,532.615 ↓ 21.3 4,327 1

Append (cost=48.67..16,979.04 rows=203 width=11) (actual time=4.009..17,532.615 rows=4,327 loops=1)

5. 21.902 206.185 ↓ 17.7 3,570 1

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

6. 9.833 102.579 ↓ 101.1 20,426 1

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

7. 21.572 22.674 ↓ 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.242..22.674 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
8. 1.102 1.102 ↓ 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.102..1.102 rows=7,908 loops=1)

  • Index Cond: (propriedade_id = 3144)
9. 70.072 70.072 ↓ 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.007..0.019 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
10. 81.704 81.704 ↑ 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.004..0.004 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[])))
11. 0.755 17,325.488 ↓ 757.0 757 1

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

12. 3.531 17,313.222 ↓ 3,837.0 3,837 1

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

13. 17,294.265 17,294.265 ↓ 1,028.4 5,142 1

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

14. 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
15. 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
Planning time : 1.951 ms
Execution time : 17,546.234 ms