explain.depesz.com

PostgreSQL's explain analyze made readable

Result: jwxO

Settings
# exclusive inclusive rows x rows loops node
1. 21.541 382.131 ↑ 210.7 19 1

Hash Anti Join (cost=42,974.15..43,593.05 rows=4,004 width=134) (actual time=74.310..382.131 rows=19 loops=1)

  • Hash Cond: ((posicoes_dia.data_venc = posicoes_d_1.data_venc) AND ((posicoes_dia.tipo_titu)::text = (posicoes_d_1.tipo_titu)::text) AND (posicoes_dia.cod_loc = posicoes_d_1.cod_loc) AND (posicoes_dia.cod_cli = posicoes_d_1.cod_cli) AND (posicoes_dia.data_atu = posicoes_d_1.data_atu) AND (posicoes_dia.id_contract = posicoes_d_1.id_contract) AND (posicoes_dia.data_compra = posicoes_d_1.data_compra) AND (posicoes_dia.data_liqd_compra = posicoes_d_1.data_liqd_compra))
2.          

CTE posicoes_dia

3. 18.658 18.658 ↓ 1.8 22,193 1

Index Scan using idx1_tb_custody_bov_treasury_direct_hist on tb_custody_bov_treasury_direct_hist (cost=0.56..21,185.57 rows=12,060 width=57) (actual time=0.139..18.658 rows=22,193 loops=1)

  • Index Cond: ((id_contract = 8) AND (data_movto = '20200107'::numeric))
4.          

CTE posicoes_d_1

5. 20.147 20.147 ↓ 1.8 22,302 1

Index Scan using idx1_tb_custody_bov_treasury_direct_hist on tb_custody_bov_treasury_direct_hist tb_custody_bov_treasury_direct_hist_1 (cost=0.56..21,185.57 rows=12,060 width=57) (actual time=0.066..20.147 rows=22,302 loops=1)

  • Index Cond: ((id_contract = 8) AND (data_movto = '20200106'::numeric))
6. 286.883 286.883 ↓ 2.5 10,040 1

CTE Scan on posicoes_dia (cost=0.00..301.50 rows=4,020 width=134) (actual time=0.155..286.883 rows=10,040 loops=1)

  • Filter: ((data_atu - data_compra) > 5)
  • Rows Removed by Filter: 12,153
7. 23.819 73.707 ↓ 1.8 22,302 1

Hash (cost=241.20..241.20 rows=12,060 width=86) (actual time=73.707..73.707 rows=22,302 loops=1)

  • Buckets: 32,768 (originally 16384) Batches: 1 (originally 1) Memory Usage: 1,827kB
8. 49.888 49.888 ↓ 1.8 22,302 1

CTE Scan on posicoes_d_1 (cost=0.00..241.20 rows=12,060 width=86) (actual time=0.072..49.888 rows=22,302 loops=1)

Planning time : 2.756 ms
Execution time : 383.926 ms