explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RhZB

Settings
# exclusive inclusive rows x rows loops node
1. 0.021 4,390.110 ↓ 0.0 0 1

Sort (cost=1,113,805.13..1,113,805.14 rows=1 width=581) (actual time=4,390.110..4,390.110 rows=0 loops=1)

  • Sort Key: ((SubPlan 1)), ((SubPlan 2))
  • Sort Method: quicksort Memory: 25kB
2. 0.001 4,390.089 ↓ 0.0 0 1

Nested Loop Anti Join (cost=0.29..1,113,805.12 rows=1 width=581) (actual time=4,390.089..4,390.089 rows=0 loops=1)

  • Join Filter: (ocp_.cd_ordem = ordem_carregamento.cd_ordem)
3. 7.498 4,390.088 ↓ 0.0 0 1

Index Scan using idx_ordem_carregamento_cd_lote on ordem_carregamento (cost=0.29..1,110,300.93 rows=1 width=571) (actual time=4,390.088..4,390.088 rows=0 loops=1)

  • Index Cond: (cd_lote = 402)
  • Filter: ((id_situacao <> 0) AND (COALESCE((SubPlan 5), '2019-07-02'::date) = '2019-07-02'::date) AND CASE WHEN ((SubPlan 3) = 1) THEN ((SubPlan 4) = '2019-07-02'::date) ELSE ((COALESCE((dt_embarque)::date, (dt_emissao)::date) <= '2019-07-02'::date) AND (dt_validade >= '2019-07-02'::date)) END)
  • Rows Removed by Filter: 418
4.          

SubPlan (for Index Scan)

5. 1.254 6.270 ↓ 0.0 0 418

Limit (cost=0.42..2.64 rows=1 width=4) (actual time=0.015..0.015 rows=0 loops=418)

6. 5.016 5.016 ↓ 0.0 0 418

Index Scan using idx_ctrc_cd_ordem_carregamento on ctrc c__2 (cost=0.42..2.64 rows=1 width=4) (actual time=0.012..0.012 rows=0 loops=418)

  • Index Cond: (cd_ordem = ordem_carregamento.cd_ordem)
  • Filter: (dt_cancelamento IS NULL)
7. 1.664 4,376.320 ↑ 1.0 1 416

Limit (cost=1,295.26..1,295.27 rows=1 width=8) (actual time=10.518..10.520 rows=1 loops=416)

8. 1.664 4,374.656 ↑ 1.0 1 416

Aggregate (cost=1,295.26..1,295.27 rows=1 width=8) (actual time=10.516..10.516 rows=1 loops=416)

9. 5.824 4,372.992 ↓ 0.0 0 416

Nested Loop (cost=0.42..1,295.26 rows=1 width=0) (actual time=10.512..10.512 rows=0 loops=416)

10. 4,366.336 4,366.336 ↑ 1.0 1 416

Seq Scan on ordem_carregamento_produto ocp__1 (cost=0.00..1,290.40 rows=1 width=4) (actual time=4.955..10.496 rows=1 loops=416)

  • Filter: ((nr_item IS NULL) AND (nr_pedido IS NULL) AND (ds_senha IS NULL) AND (cd_ordem = ordem_carregamento.cd_ordem))
  • Rows Removed by Filter: 61910
11. 0.832 0.832 ↓ 0.0 0 416

Index Only Scan using pk_ctrc on ctrc c_ (cost=0.42..2.64 rows=1 width=4) (actual time=0.001..0.002 rows=0 loops=416)

  • Index Cond: (cd_ctrc = ocp__1.cd_ctrc)
  • Heap Fetches: 0
12. 0.000 0.000 ↓ 0.0 0

Limit (cost=0.42..1,295.26 rows=1 width=4) (never executed)

13. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..1,295.26 rows=1 width=4) (never executed)

14. 0.000 0.000 ↓ 0.0 0

Seq Scan on ordem_carregamento_produto ocp__2 (cost=0.00..1,290.40 rows=1 width=4) (never executed)

  • Filter: ((nr_item IS NULL) AND (nr_pedido IS NULL) AND (ds_senha IS NULL) AND (cd_ordem = ordem_carregamento.cd_ordem))
15. 0.000 0.000 ↓ 0.0 0

Index Only Scan using pk_ctrc on ctrc c__1 (cost=0.42..2.64 rows=1 width=4) (never executed)

  • Index Cond: (cd_ctrc = ocp__2.cd_ctrc)
  • Heap Fetches: 0
16. 0.000 0.000 ↓ 0.0 0

Seq Scan on ordem_carregamento_produto ocp_ (cost=0.00..1,135.72 rows=1 width=4) (never executed)

  • Filter: ((nr_item IS NOT NULL) AND (nr_pedido IS NOT NULL) AND (ds_senha IS NOT NULL))
17.          

SubPlan (for Nested Loop Anti Join)

18. 0.000 0.000 ↓ 0.0 0

Limit (cost=1,184.22..1,184.23 rows=1 width=10) (never executed)

19. 0.000 0.000 ↓ 0.0 0

Sort (cost=1,184.22..1,184.23 rows=1 width=10) (never executed)

  • Sort Key: ocs_.dt_status DESC
20. 0.000 0.000 ↓ 0.0 0

Seq Scan on ordem_carregamento_status ocs_ (cost=0.00..1,184.21 rows=1 width=10) (never executed)

  • Filter: (cd_ordem = ordem_carregamento.cd_ordem)
21. 0.000 0.000 ↓ 0.0 0

Limit (cost=1,184.22..1,184.23 rows=1 width=8) (never executed)

22. 0.000 0.000 ↓ 0.0 0

Sort (cost=1,184.22..1,184.23 rows=1 width=8) (never executed)

  • Sort Key: ocs__1.dt_status DESC
23. 0.000 0.000 ↓ 0.0 0

Seq Scan on ordem_carregamento_status ocs__1 (cost=0.00..1,184.21 rows=1 width=8) (never executed)

  • Filter: (cd_ordem = ordem_carregamento.cd_ordem)
Planning time : 1.557 ms
Execution time : 4,390.457 ms