explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RRj9

Settings
# exclusive inclusive rows x rows loops node
1. 0.006 60.161 ↑ 1.0 1 1

Limit (cost=47,207.52..47,207.53 rows=1 width=61) (actual time=60.157..60.161 rows=1 loops=1)

2. 4.503 60.155 ↑ 6,956.0 1 1

Sort (cost=47,207.52..47,224.91 rows=6,956 width=61) (actual time=60.155..60.155 rows=1 loops=1)

  • Sort Key: ((prm.prm_fl_tipo_documento = ANY ('{C,S,E,M}'::bpchar[]))) DESC, ((prm.prm_dt_movimento + prm.prm_tm_movimento)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
3. 15.415 55.652 ↓ 3.2 22,460 1

WindowAgg (cost=22,929.86..47,172.74 rows=6,956 width=61) (actual time=50.828..55.652 rows=22,460 loops=1)

4. 2.193 40.237 ↓ 3.2 22,460 1

Nested Loop (cost=22,929.86..46,372.80 rows=6,956 width=41) (actual time=22.186..40.237 rows=22,460 loops=1)

5. 0.001 22.178 ↑ 1.0 1 1

Nested Loop Left Join (cost=22,929.42..22,940.08 rows=1 width=20) (actual time=22.175..22.178 rows=1 loops=1)

  • Join Filter: (prm_1.prm_fl_tipo_documento = 'E'::bpchar)
6. 0.003 22.172 ↑ 1.0 1 1

Nested Loop Left Join (cost=22,928.99..22,937.25 rows=1 width=19) (actual time=22.168..22.172 rows=1 loops=1)

  • Join Filter: (prm_1.prm_fl_tipo_documento = 'C'::bpchar)
  • Rows Removed by Join Filter: 1
7. 0.004 22.162 ↑ 1.0 1 1

Nested Loop Left Join (cost=22,928.43..22,934.27 rows=1 width=13) (actual time=22.159..22.162 rows=1 loops=1)

  • Join Filter: (prm_1.prm_fl_tipo_documento = 'S'::bpchar)
8. 0.002 22.128 ↑ 1.0 1 1

Limit (cost=22,927.29..22,927.29 rows=1 width=15) (actual time=22.126..22.128 rows=1 loops=1)

9. 4.103 22.126 ↑ 6,866.0 1 1

Sort (cost=22,927.29..22,944.45 rows=6,866 width=15) (actual time=22.126..22.126 rows=1 loops=1)

  • Sort Key: ((prm_1.prm_fl_tipo_documento = ANY ('{C,S,E,M}'::bpchar[]))) DESC, ((prm_1.prm_dt_movimento + prm_1.prm_tm_movimento)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
10. 18.023 18.023 ↓ 3.3 22,458 1

Index Scan using produto_movimento_idx_produto_unidade_negocio on produto_movimento prm_1 (cost=0.43..22,892.96 rows=6,866 width=15) (actual time=0.013..18.023 rows=22,458 loops=1)

  • Index Cond: (prm_cd_produto_unidade_negocio = 292710)
  • Filter: ((prm_fl_tipo_documento = ANY ('{C,S,E,M}'::bpchar[])) AND ((prm_dt_movimento + prm_tm_movimento) <= '2019-08-12 13:02:14'::timestamp without time zone))
  • Rows Removed by Filter: 2
11. 0.004 0.030 ↑ 1.0 1 1

Nested Loop (cost=1.14..6.78 rows=1 width=11) (actual time=0.028..0.030 rows=1 loops=1)

12. 0.003 0.019 ↑ 1.0 1 1

Nested Loop (cost=0.85..4.77 rows=1 width=15) (actual time=0.018..0.019 rows=1 loops=1)

13. 0.009 0.009 ↑ 1.0 1 1

Index Scan using nota_saida_item_pkey on nota_saida_item nsi (cost=0.42..2.73 rows=1 width=19) (actual time=0.008..0.009 rows=1 loops=1)

  • Index Cond: (nsi_cd_nota_saida_item = prm_1.prm_cd_documento)
14. 0.007 0.007 ↑ 1.0 1 1

Index Scan using nota_saida_pkey on nota_saida nts (cost=0.42..2.04 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=1)

  • Index Cond: (nts_cd_nota_saida = nsi.nsi_cd_nota_saida)
  • Filter: (nts_fl_tipo = 'S'::bpchar)
15. 0.007 0.007 ↑ 1.0 1 1

Index Scan using cfop_pkey on cfop cfo (cost=0.29..2.01 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=1)

  • Index Cond: (cfo_cd_cfop = nsi.nsi_cd_cfop)
  • Filter: ((cfo_ds_cfop)::text <> ALL ('{5.929,6.929,5.411,5.412,5.413,5.503,5.553,5.555,5.556,7.201,7.202,6.918,6.201,6.202,5.918,6.208,6.209,3.503,3.553,6.921,7.210,7.211,5.201,2.410,2.411,5.202,2.903,5.208,5.209,6.660,2.503,2.504,2.553,5.921,6.210,6.661,6.662,1.410,1.411,5.660,5.661,1.503,1.504,1.553,5.210,5.662,3.201,3.202,2.918,2.201,2.202,2.204,1.918,2.208,2.209,3.211,1.201,1.202,1.203,1.204,1.208,1.209,2.660,2.661,2.662,7.553,7.556,6.410,6.411,6.412,6.413,1.660,1.661,1.662,6.503,6.553,6.555,6.556,5.410}'::text[]))
16. 0.007 0.007 ↑ 1.0 1 1

Index Scan using venda_item_pkey on venda_item vei (cost=0.57..2.88 rows=1 width=10) (actual time=0.007..0.007 rows=1 loops=1)

  • Index Cond: (vei_cd_venda_item = prm_1.prm_cd_documento)
17. 0.005 0.005 ↓ 0.0 0 1

Index Scan using nota_entrada_item_pkey on nota_entrada_item nei (cost=0.43..2.74 rows=1 width=11) (actual time=0.005..0.005 rows=0 loops=1)

  • Index Cond: (nei_cd_nota_entrada_item = prm_1.prm_cd_documento)
18. 15.866 15.866 ↓ 3.2 22,460 1

Index Scan using produto_movimento_idx_produto_unidade_negocio on produto_movimento prm (cost=0.43..22,737.12 rows=6,956 width=21) (actual time=0.009..15.866 rows=22,460 loops=1)

  • Index Cond: (prm_cd_produto_unidade_negocio = 292710)
  • Filter: ((prm_dt_movimento + prm_tm_movimento) <= '2019-08-12 13:02:14'::timestamp without time zone)
Planning time : 0.947 ms
Execution time : 60.234 ms