explain.depesz.com

PostgreSQL's explain analyze made readable

Result: diTK

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Sort (cost=60,222.20..60,222.20 rows=1 width=156) (actual rows= loops=)

  • Sort Key: (row_number() OVER (?))
2. 0.000 0.000 ↓ 0.0

WindowAgg (cost=60,221.87..60,222.19 rows=1 width=156) (actual rows= loops=)

3. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=60,221.87..60,222.16 rows=1 width=53) (actual rows= loops=)

  • Group Key: patbem.cd_pat_grupo, patgru.no_pat_grupo
  • Filter: ((sum(COALESCE(CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{IA,IC,IM,IE,DP,TE,CM,DE,IO,AO}'::text[])) THEN COALESCE(patbemmov.vl_hist, '0'::numeric) ELSE CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{TS,VE,PE,DM,BO,BA}'::text[])) THEN COALESCE((patbemmov.vl_hist * '-1'::numeric), '0'::numeric) ELSE NULL::numeric END END, '0'::numeric)) <> '0'::numeric) OR (sum(COALESCE(CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{IA,IC,IM,IE,DP,TE,CM,DE,IO,AO}'::text[])) THEN COALESCE(patbemmov.vl_depr_fisc, '0'::numeric) ELSE CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{TS,VE,PE,DM,BO,BA}'::text[])) THEN COALESCE((patbemmov.vl_depr_fisc * '-1'::numeric), '0'::numeric) ELSE NULL::numeric END END, '0'::numeric)) <> '0'::numeric) OR (sum(COALESCE(CASE WHEN (((opepat.id_tipo_operacao)::text = 'DP'::text) AND (patbemmov.dt_movimento >= to_date('2019-01-01'::text, 'yyyy-MM-dd'::text)) AND (patbemmov.dt_movimento <= to_date('2019-01-31'::text, 'yyyy-MM-dd'::text))) THEN COALESCE(patbemmov.vl_depr_fisc, '0'::numeric) ELSE '0'::numeric END, '0'::numeric)) <> '0'::numeric) OR (COALESCE((COALESCE(sum(COALESCE(CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{IA,IC,IM,IE,DP,TE,CM,DE,IO,AO}'::text[])) THEN COALESCE(patbemmov.vl_hist, '0'::numeric) ELSE CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{TS,VE,PE,DM,BO,BA}'::text[])) THEN COALESCE((patbemmov.vl_hist * '-1'::numeric), '0'::numeric) ELSE NULL::numeric END END, '0'::numeric)), '0'::numeric) - COALESCE(sum(COALESCE(CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{IA,IC,IM,IE,DP,TE,CM,DE,IO,AO}'::text[])) THEN COALESCE(patbemmov.vl_depr_fisc, '0'::numeric) ELSE CASE WHEN ((opepat.id_tipo_operacao)::text = ANY ('{TS,VE,PE,DM,BO,BA}'::text[])) THEN COALESCE((patbemmov.vl_depr_fisc * '-1'::numeric), '0'::numeric) ELSE NULL::numeric END END, '0'::numeric)), '0'::numeric)), '0'::numeric) <> '0'::numeric))
4. 0.000 0.000 ↓ 0.0

Sort (cost=60,221.87..60,221.88 rows=1 width=53) (actual rows= loops=)

  • Sort Key: patbem.cd_pat_grupo, patgru.no_pat_grupo
5. 0.000 0.000 ↓ 0.0

Nested Loop (cost=5,528.07..60,221.86 rows=1 width=53) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Nested Loop (cost=5,527.93..60,221.70 rows=1 width=49) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Nested Loop (cost=5,527.79..60,221.53 rows=1 width=33) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Nested Loop (cost=5,527.50..60,221.20 rows=1 width=45) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Hash Anti Join (cost=5,527.08..59,987.45 rows=1 width=37) (actual rows= loops=)

  • Hash Cond: ((patbemmov.cd_empresa = procan.cd_empresa) AND (patbemmov.cd_base = procan.cd_base) AND (patbemmov.seq_processo = procan.seq_processo))
10. 0.000 0.000 ↓ 0.0

Seq Scan on pat_bem_mov patbemmov (cost=0.00..41,835.62 rows=1,122,200 width=53) (actual rows= loops=)

  • Filter: ((cd_empresa = 1) AND (dt_movimento <= to_date('2019-01-31'::text, 'yyyy-MM-dd'::text)))
11. 0.000 0.000 ↓ 0.0

Hash (cost=3,263.70..3,263.70 rows=129,336 width=24) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Seq Scan on processo_canc procan (cost=0.00..3,263.70 rows=129,336 width=24) (actual rows= loops=)

  • Filter: (cd_empresa = 1)
13. 0.000 0.000 ↓ 0.0

Index Only Scan using pat_bem_local_pk on pat_bem_local patbemloc (cost=0.42..233.74 rows=1 width=16) (actual rows= loops=)

  • Index Cond: ((cd_empresa = 1) AND (cd_bem = patbemmov.cd_bem))
  • Filter: ((to_char((dt_alt_local)::timestamp with time zone, 'YYYYMMDD'::text) || (hr_alt_local)::text) = (SubPlan 1))
14.          

SubPlan (forIndex Only Scan)

15. 0.000 0.000 ↓ 0.0

Aggregate (cost=46.62..46.63 rows=1 width=11) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Nested Loop Anti Join (cost=0.84..46.57 rows=5 width=11) (actual rows= loops=)

17. 0.000 0.000 ↓ 0.0

Index Scan using pat_bem_local_pk on pat_bem_local patbemlocaux (cost=0.42..15.54 rows=5 width=35) (actual rows= loops=)

  • Index Cond: ((cd_empresa = patbemloc.cd_empresa) AND (cd_bem = patbemloc.cd_bem) AND (dt_alt_local <= to_date('2019-01-31'::text, 'yyyy-MM-dd'::text)))
18. 0.000 0.000 ↓ 0.0

Index Only Scan using processo_canc_pk on processo_canc procan_1 (cost=0.42..5.24 rows=1 width=24) (actual rows= loops=)

  • Index Cond: ((cd_empresa = patbemlocaux.cd_empresa) AND (cd_empresa = patbemloc.cd_empresa) AND (cd_base = patbemlocaux.cd_base) AND (seq_processo = patbemlocaux.seq_processo))
19. 0.000 0.000 ↓ 0.0

Index Scan using pat_bem_pk on pat_bem patbem (cost=0.29..0.32 rows=1 width=20) (actual rows= loops=)

  • Index Cond: ((cd_empresa = 1) AND (cd_bem = patbemmov.cd_bem))
20. 0.000 0.000 ↓ 0.0

Index Scan using pat_grupo_pk on pat_grupo patgru (cost=0.14..0.16 rows=1 width=36) (actual rows= loops=)

  • Index Cond: ((cd_empresa = 1) AND ((cd_pat_grupo)::text = (patbem.cd_pat_grupo)::text))
21. 0.000 0.000 ↓ 0.0

Index Scan using operacao_patrimonio_pk on operacao_patrimonio opepat (cost=0.14..0.16 rows=1 width=20) (actual rows= loops=)

  • Index Cond: (cd_operacao = patbemmov.cd_operacao)