explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 0h54

Settings
# exclusive inclusive rows x rows loops node
1. 6,821.373 6,821.373 ↓ 1.8 126 1

CTE Scan on analise (cost=85,197.54..85,216.24 rows=70 width=332) (actual time=6,820.466..6,821.373 rows=126 loops=1)

  • Filter: ((precisao > '75'::numeric) AND ((preco_previsto - preco_final) > '0'::numeric))
  • Rows Removed by Filter: 526
2.          

CTE acoes

3. 1.017 23.821 ↓ 1.0 652 1

Sort (cost=1,160.92..1,162.50 rows=632 width=6) (actual time=23.426..23.821 rows=652 loops=1)

  • Sort Key: cotacao.acao
  • Sort Method: quicksort Memory: 42kB
4. 16.021 22.804 ↓ 1.0 652 1

HashAggregate (cost=1,125.20..1,131.52 rows=632 width=6) (actual time=22.694..22.804 rows=652 loops=1)

  • Group Key: cotacao.acao
5. 6.783 6.783 ↑ 1.0 59,776 1

Seq Scan on cotacao (cost=0.00..975.76 rows=59,776 width=6) (actual time=0.027..6.783 rows=59,776 loops=1)

6.          

CTE periodo

7. 0.001 0.001 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=20) (actual time=0.001..0.001 rows=1 loops=1)

8.          

CTE analise

9. 2.043 6,820.502 ↓ 1.0 652 1

Sort (cost=84,033.46..84,035.03 rows=629 width=268) (actual time=6,820.450..6,820.502 rows=652 loops=1)

  • Sort Key: acoes.acao
  • Sort Method: quicksort Memory: 97kB
10. 19.959 6,818.459 ↓ 1.0 652 1

Nested Loop (cost=0.00..84,004.22 rows=629 width=268) (actual time=31.397..6,818.459 rows=652 loops=1)

11. 0.060 0.060 ↑ 1.0 1 1

CTE Scan on periodo (cost=0.00..0.02 rows=1 width=20) (actual time=0.006..0.060 rows=1 loops=1)

12. 24.812 24.812 ↓ 1.0 652 1

CTE Scan on acoes (cost=0.00..14.22 rows=629 width=32) (actual time=23.428..24.812 rows=652 loops=1)

  • Filter: (acao <> ''::text)
13.          

SubPlan (forNested Loop)

14. 1.304 406.196 ↑ 1.0 1 652

Limit (cost=0.41..18.17 rows=1 width=10) (actual time=0.623..0.623 rows=1 loops=652)

15. 404.892 404.892 ↑ 32.0 1 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_1 (cost=0.41..568.49 rows=32 width=10) (actual time=0.621..0.621 rows=1 loops=652)

  • Index Cond: ((data <= periodo.datainicial) AND (acao = acoes.acao))
16. 1.304 236.676 ↑ 1.0 1 652

Limit (cost=0.41..18.17 rows=1 width=10) (actual time=0.362..0.363 rows=1 loops=652)

17. 235.372 235.372 ↑ 32.0 1 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_2 (cost=0.41..568.49 rows=32 width=10) (actual time=0.361..0.361 rows=1 loops=652)

  • Index Cond: ((data <= periodo.datafinal) AND (acao = acoes.acao))
18. 31.296 1,033.420 ↑ 1.0 1 652

Aggregate (cost=16.18..16.19 rows=1 width=32) (actual time=1.585..1.585 rows=1 loops=652)

19. 1,002.124 1,002.124 ↓ 24.0 24 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_3 (cost=0.41..16.16 rows=1 width=10) (actual time=0.301..1.537 rows=24 loops=652)

  • Index Cond: ((data >= periodo.datainicial) AND (data <= periodo.datafinal) AND (acao = acoes.acao))
20. 29.340 1,017.120 ↑ 1.0 1 652

Aggregate (cost=16.18..16.19 rows=1 width=32) (actual time=1.559..1.560 rows=1 loops=652)

21. 987.780 987.780 ↓ 24.0 24 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_4 (cost=0.41..16.16 rows=1 width=10) (actual time=0.289..1.515 rows=24 loops=652)

  • Index Cond: ((data >= periodo.datainicial) AND (data <= periodo.datafinal) AND (acao = acoes.acao))
22. 29.340 1,019.728 ↑ 1.0 1 652

Aggregate (cost=16.18..16.19 rows=1 width=32) (actual time=1.564..1.564 rows=1 loops=652)

23. 990.388 990.388 ↓ 24.0 24 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_5 (cost=0.41..16.16 rows=1 width=10) (actual time=0.287..1.519 rows=24 loops=652)

  • Index Cond: ((data >= periodo.datainicial) AND (data <= periodo.datafinal) AND (acao = acoes.acao))
24. 29.992 1,027.552 ↑ 1.0 1 652

Aggregate (cost=16.18..16.19 rows=1 width=32) (actual time=1.575..1.576 rows=1 loops=652)

25. 997.560 997.560 ↓ 24.0 24 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_6 (cost=0.41..16.16 rows=1 width=10) (actual time=0.286..1.530 rows=24 loops=652)

  • Index Cond: ((data >= periodo.datainicial) AND (data <= periodo.datafinal) AND (acao = acoes.acao))
26. 29.340 1,032.768 ↑ 1.0 1 652

Aggregate (cost=16.18..16.20 rows=1 width=32) (actual time=1.584..1.584 rows=1 loops=652)

27. 1,003.428 1,003.428 ↓ 24.0 24 652

Index Scan using uidx_cotacao_data_codigo on cotacao cotacao_7 (cost=0.41..16.16 rows=1 width=10) (actual time=0.296..1.539 rows=24 loops=652)

  • Index Cond: ((data >= periodo.datainicial) AND (data <= periodo.datafinal) AND (acao = acoes.acao))
28. 4.564 1,000.168 ↑ 1.0 1 652

Aggregate (cost=16.17..16.18 rows=1 width=8) (actual time=1.533..1.534 rows=1 loops=652)

29. 995.604 995.604 ↓ 24.0 24 652

Index Only Scan using uidx_cotacao_data_codigo on cotacao cotacao_8 (cost=0.41..16.16 rows=1 width=0) (actual time=0.290..1.527 rows=24 loops=652)

  • Index Cond: ((data >= periodo.datainicial) AND (data <= periodo.datafinal) AND (acao = acoes.acao))
  • Heap Fetches: 15522
Planning time : 1.427 ms
Execution time : 6,821.925 ms