explain.depesz.com

PostgreSQL's explain analyze made readable

Result: p7EP

Settings
# exclusive inclusive rows x rows loops node
1. 6.813 28,870.645 ↓ 331.8 4,645 1

WindowAgg (cost=366,279.51..366,279.96 rows=14 width=57) (actual time=28,862.849..28,870.645 rows=4,645 loops=1)

2.          

CTE femeas_paridas_antes_em

3. 31.169 509.411 ↓ 24.9 33,935 1

WindowAgg (cost=183,045.06..183,072.30 rows=1,362 width=33) (actual time=471.159..509.411 rows=33,935 loops=1)

4. 29.392 478.242 ↓ 24.9 33,935 1

Sort (cost=183,045.06..183,048.46 rows=1,362 width=25) (actual time=471.135..478.242 rows=33,935 loops=1)

  • Sort Key: vw_1.femea_id, vw_1.data_hora_cobertura DESC
  • Sort Method: quicksort Memory: 4,155kB
5. 448.850 448.850 ↓ 24.9 33,935 1

Index Scan using vw_modelo_reprodutivo_parto_id_idx2 on vw_modelo_reprodutivo vw_1 (cost=0.56..182,974.16 rows=1,362 width=25) (actual time=64.479..448.850 rows=33,935 loops=1)

  • Index Cond: (propriedade_id = 3,162)
  • Filter: ((data_hora_cobertura < '2019-11-10 00:00:00-03'::timestamp with time zone) AND (contrato_id = 16))
  • Rows Removed by Filter: 4,645
6. 19.428 28,863.832 ↓ 331.8 4,645 1

Sort (cost=183,207.21..183,207.24 rows=14 width=45) (actual time=28,862.818..28,863.832 rows=4,645 loops=1)

  • Sort Key: vw.femea_id, vw.data_hora_cobertura
  • Sort Method: quicksort Memory: 667kB
7. 1,574.219 28,844.404 ↓ 331.8 4,645 1

Nested Loop Left Join (cost=0.56..183,206.94 rows=14 width=45) (actual time=717.283..28,844.404 rows=4,645 loops=1)

  • Join Filter: (vw.femea_id = fp.femea_id)
  • Rows Removed by Join Filter: 17,035,137
8. 417.440 417.440 ↓ 331.8 4,645 1

Index Scan using vw_modelo_reprodutivo_parto_id_idx2 on vw_modelo_reprodutivo vw (cost=0.56..183,172.59 rows=14 width=41) (actual time=199.973..417.440 rows=4,645 loops=1)

  • Index Cond: (propriedade_id = 3,162)
  • Filter: ((data_hora_cobertura >= '2019-11-10 00:00:00-03'::timestamp with time zone) AND (data_hora_cobertura <= '2020-03-15 00:00:00-03'::timestamp with time zone) AND (contrato_id = 16) AND (tipo_cobertura = 'IA'::text))
  • Rows Removed by Filter: 33,935
9. 26,852.745 26,852.745 ↓ 3,668.0 3,668 4,645

CTE Scan on femeas_paridas_antes_em fp (cost=0.00..34.05 rows=1 width=8) (actual time=0.102..5.781 rows=3,668 loops=4,645)

  • Filter: ((ordem = 1) AND (situacao_cria = 'Vivo'::text))
  • Rows Removed by Filter: 30,267
Planning time : 0.633 ms
Execution time : 28,872.768 ms