explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2Vnw

Settings
# exclusive inclusive rows x rows loops node
1. 10.395 2,392.479 ↑ 1.7 17,357 1

WindowAgg (cost=372,984.65..377,842.79 rows=29,401 width=21) (actual time=2,260.998..2,392.479 rows=17,357 loops=1)

2. 73.349 2,382.084 ↑ 1.7 17,357 1

GroupAggregate (cost=372,984.65..377,254.77 rows=29,401 width=21) (actual time=2,260.986..2,382.084 rows=17,357 loops=1)

  • Group Key: iv.cod_rede, iv.cod_filial, iv.cod_reduzido
3. 330.572 2,308.735 ↑ 1.2 208,457 1

Sort (cost=372,984.65..373,635.09 rows=260,174 width=21) (actual time=2,260.964..2,308.735 rows=208,457 loops=1)

  • Sort Key: iv.cod_rede, iv.cod_filial, iv.cod_reduzido
  • Sort Method: external merge Disk: 6904kB
4. 198.025 1,978.163 ↑ 1.2 208,457 1

Merge Join (cost=60,312.70..344,245.65 rows=260,174 width=21) (actual time=1,511.454..1,978.163 rows=208,457 loops=1)

  • Merge Cond: ((iv.cod_rede = cv.cod_rede) AND (iv.cod_filial = cv.cod_filial) AND (iv.num_nota = cv.num_nota))
5. 1,483.803 1,483.803 ↑ 1.0 2,149,342 1

Index Scan using fki_cadivend_num_nota_fkey on cadivend iv (cost=0.43..262,057.88 rows=2,179,619 width=21) (actual time=0.065..1,483.803 rows=2,149,342 loops=1)

  • Filter: ((COALESCE(flg_excluido, 'N'::bpchar) <> 'S'::bpchar) AND (flg_estoque = 'S'::bpchar))
  • Rows Removed by Filter: 64081
6. 14.493 296.335 ↓ 1.6 208,451 1

Materialize (cost=60,312.27..60,962.03 rows=129,953 width=16) (actual time=270.979..296.335 rows=208,451 loops=1)

7. 102.885 281.842 ↑ 1.4 91,922 1

Sort (cost=60,312.27..60,637.15 rows=129,953 width=16) (actual time=270.954..281.842 rows=91,922 loops=1)

  • Sort Key: cv.cod_rede, cv.cod_filial, cv.num_nota
  • Sort Method: external sort Disk: 2336kB
8. 118.533 178.957 ↑ 1.4 91,922 1

Bitmap Heap Scan on cadcvend cv (cost=3,423.53..47,051.80 rows=129,953 width=16) (actual time=61.630..178.957 rows=91,922 loops=1)

  • Recheck Cond: ((dat_emissao >= (now() - '1 year'::interval)) AND (tip_venda = 'V'::bpchar))
  • Filter: ((flg_sitcaixa IS NOT NULL) AND (COALESCE(flg_excluido, 'N'::bpchar) <> 'S'::bpchar) AND (date_part('dow'::text, (dat_emissao)::timestamp without time zone) <> ALL ('{0,6}'::double precision[])))
  • Rows Removed by Filter: 44869
  • Heap Blocks: exact=7366
9. 60.424 60.424 ↓ 1.0 136,791 1

Bitmap Index Scan on idx_cadcvend_dat_emissao_flg_excluido_tip_venda (cost=0.00..3,391.04 rows=132,509 width=0) (actual time=60.424..60.424 rows=136,791 loops=1)

  • Index Cond: ((dat_emissao >= (now() - '1 year'::interval)) AND (tip_venda = 'V'::bpchar))
Planning time : 2.813 ms
Execution time : 2,394.811 ms