explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kDHW

Settings
# exclusive inclusive rows x rows loops node
1. 1,727.081 14,614.137 ↓ 51.0 51 1

GroupAggregate (cost=13,474.35..13,474.49 rows=1 width=54) (actual time=13,076.882..14,614.137 rows=51 loops=1)

  • Group Key: patbemloc.cd_filial, pes.no_reduzido
2. 710.573 12,887.056 ↓ 747,271.0 747,271 1

Sort (cost=13,474.35..13,474.35 rows=1 width=54) (actual time=12,781.352..12,887.056 rows=747,271 loops=1)

  • Sort Key: patbemloc.cd_filial, pes.no_reduzido
  • Sort Method: quicksort Memory: 83844kB
3. 346.183 12,176.483 ↓ 747,271.0 747,271 1

Nested Loop (cost=12,535.99..13,474.34 rows=1 width=54) (actual time=1,386.497..12,176.483 rows=747,271 loops=1)

4. 825.977 10,335.758 ↓ 747,271.0 747,271 1

Nested Loop Anti Join (cost=12,535.85..13,474.17 rows=1 width=50) (actual time=1,386.483..10,335.758 rows=747,271 loops=1)

5. 360.048 5,771.206 ↓ 28,758.3 747,715 1

Nested Loop (cost=12,535.43..13,462.36 rows=26 width=74) (actual time=1,386.443..5,771.206 rows=747,715 loops=1)

  • Join Filter: (patbem.cd_bem = patbemmov.cd_bem)
6. 28.542 2,594.620 ↓ 16,187.0 16,187 1

Nested Loop (cost=12,535.00..13,459.57 rows=1 width=69) (actual time=1,386.375..2,594.620 rows=16,187 loops=1)

7. 24.757 2,452.769 ↓ 16,187.0 16,187 1

Nested Loop (cost=12,534.71..13,459.18 rows=1 width=64) (actual time=1,386.350..2,452.769 rows=16,187 loops=1)

8. 55.487 2,330.890 ↓ 16,187.0 16,187 1

Nested Loop (cost=12,534.57..13,457.01 rows=1 width=68) (actual time=1,386.297..2,330.890 rows=16,187 loops=1)

  • Join Filter: (pat_bem_local.cd_bem = patbem.cd_bem)
9. 300.260 1,762.823 ↓ 8,543.0 42,715 1

Hash Join (cost=12,534.28..13,455.24 rows=5 width=56) (actual time=1,386.153..1,762.823 rows=42,715 loops=1)

  • Hash Cond: ((pat_bem_local.cd_bem = patbemloc.cd_bem) AND ((max((to_char((pat_bem_local.dt_alt_local)::timestamp with time zone, 'YYYYMMDD'::text) || (pat_bem_local.hr_alt_local)::text))) = (to_char((patbemloc.dt_alt_local)::timestamp with time zone, 'YYYYMMDD'::text) || (patbemloc.hr_alt_local)::text)))
10. 680.128 760.223 ↓ 1.4 42,715 1

HashAggregate (cost=6,731.86..7,026.55 rows=29,469 width=27) (actual time=683.729..760.223 rows=42,715 loops=1)

  • Group Key: pat_bem_local.cd_empresa, pat_bem_local.cd_bem
11. 80.095 80.095 ↓ 1.0 151,797 1

Seq Scan on pat_bem_local (cost=0.00..4,465.57 rows=151,086 width=27) (actual time=0.077..80.095 rows=151,797 loops=1)

  • Filter: (cd_empresa = 1)
12. 470.763 702.340 ↓ 161.1 151,797 1

Hash (cost=5,788.28..5,788.28 rows=942 width=51) (actual time=702.340..702.340 rows=151,797 loops=1)

  • Buckets: 262144 (originally 1024) Batches: 1 (originally 1) Memory Usage: 15094kB
13. 97.146 231.577 ↓ 161.1 151,797 1

Hash Join (cost=748.59..5,788.28 rows=942 width=51) (actual time=2.153..231.577 rows=151,797 loops=1)

  • Hash Cond: (patbemloc.cd_filial = pesfil.cd_filial)
14. 132.354 132.354 ↓ 1.0 151,797 1

Seq Scan on pat_bem_local patbemloc (cost=0.00..4,465.57 rows=151,086 width=35) (actual time=0.034..132.354 rows=151,797 loops=1)

  • Filter: (cd_empresa = 1)
15. 0.059 2.077 ↓ 64.0 64 1

Hash (cost=748.57..748.57 rows=1 width=32) (actual time=2.077..2.077 rows=64 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 12kB
16. 0.097 2.018 ↓ 64.0 64 1

Nested Loop (cost=84.50..748.57 rows=1 width=32) (actual time=0.799..2.018 rows=64 loops=1)

17. 0.361 0.833 ↑ 3.6 64 1

HashAggregate (cost=84.09..86.38 rows=229 width=211) (actual time=0.751..0.833 rows=64 loops=1)

  • Group Key: pesfil.cd_empresa, pesfil.cd_filial, pesfil.id_atividade, pesfil.cd_pessoa, pesfil.cd_segmento_fiscal, pesfil.cd_lista_preco_basica, pesfil.cd_pessoa_clas_fiscal, pesfil.id_perfil_sped_fiscal, pesfil.id_periodo_inventario, pesfil.mes_inventario_anual, pesfil.versao_leiaute_nfe, pesfil.id_formato_danfe, pesfil.id_ambiente_nfe, pesfil.cd_operacao_venda, pesfil.id_volume_trans, pesfil.id_utiliza_lacre_transp, pesfil.cd_tipo_cobranca, pesfil.cd_banco_portador, pesfil.nr_agencia_portador, pesfil.nr_conta_portador, pesfil.id_clas_cons_en_eletr, pesfil.id_tipo_ligacao_default, pesfil.id_grupo_tensao_default, pesfil.id_clas_cons_gas, pesfil.id_tipo_assinante_comunic, pesfil.id_clas_cons_agua, pesfil.cd_lista_preco_tipo_basico, pesfil.cd_lista_preco_prom, pesfil.cd_lista_preco_tipo_prom, pesfil.cd_grupo_unidade_medida, pesfil.id_ecf, pesfil.id_tipo_atualizacao_est, pesfil.id_atualizando_est, pesfil.dt_ult_fec_estoque, pesfil.mes_invent_sped_anual, pesfil.id_emite_nf_conjugada, pesfil.id_origem_tipo_preco, pesfil.cd_operacao_serv, pesfil.id_obriga_cd_barras_nfe, pesfil.id_ativo, pesfil.abrev_filial, pesfil.id_geracao_nfe, pesfil.id_matriz, pesfil.cd_perfil_filial, pesfil.id_venda_saldo_terc
18. 0.007 0.472 ↑ 3.6 64 1

Append (cost=14.79..58.33 rows=229 width=211) (actual time=0.289..0.472 rows=64 loops=1)

19. 0.000 0.055 ↓ 0.0 0 1

Nested Loop (cost=14.79..23.70 rows=36 width=211) (actual time=0.055..0.055 rows=0 loops=1)

20. 0.001 0.055 ↓ 0.0 0 1

Nested Loop (cost=0.70..9.09 rows=12 width=211) (actual time=0.055..0.055 rows=0 loops=1)

21. 0.000 0.054 ↓ 0.0 0 1

Nested Loop (cost=0.56..7.00 rows=12 width=16) (actual time=0.054..0.054 rows=0 loops=1)

22. 0.054 0.054 ↓ 0.0 0 1

Index Scan using operador_uk1 on operador ope (cost=0.28..4.30 rows=1 width=9) (actual time=0.054..0.054 rows=0 loops=1)

  • Index Cond: ((seq_operador)::text = '0193'::text)
  • Filter: (id_visao_filial_todos = 'N'::bpchar)
  • Rows Removed by Filter: 1
23. 0.000 0.000 ↓ 0.0 0

Index Only Scan using operador_pessoa_filial_pk on operador_pessoa_filial opepesfil (cost=0.28..2.56 rows=14 width=23) (never executed)

  • Index Cond: ((cd_operador = (ope.cd_operador)::text) AND (cd_empresa = 1))
  • Heap Fetches: 0
24. 0.000 0.000 ↓ 0.0 0

Index Scan using pessoa_filial_pk on pessoa_filial pesfil (cost=0.14..0.16 rows=1 width=211) (never executed)

  • Index Cond: ((cd_empresa = 1) AND (cd_filial = opepesfil.cd_filial))
25. 0.000 0.000 ↓ 0.0 0

Materialize (cost=14.09..14.16 rows=3 width=8) (never executed)

26. 0.000 0.000 ↓ 0.0 0

Subquery Scan on pesemp (cost=14.09..14.14 rows=3 width=8) (never executed)

27. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=14.09..14.12 rows=3 width=112) (never executed)

  • Group Key: pesemp_1.cd_empresa, pesemp_1.cd_pessoa, pesemp_1.cd_regime_fiscal, pesemp_1.dt_baixa, pesemp_1.dt_arq_atos_const, pesemp_1.dt_arq_conv_simp_empr, pesemp_1.coef_acresc_venda_ncoop, pesemp_1.id_cooperativa, pesemp_1.id_origem_tribut, pesemp_1.id_controla_fci, pesemp_1.nr_max_itens_nfe, pesemp_1.id_valida_cest_fat, pesemp_1.id_consiste_ncm_xml, pesemp_1.nr_dias_rev_cad_cli_ven
28. 0.000 0.000 ↓ 0.0 0

Append (cost=0.55..13.98 rows=3 width=112) (never executed)

29. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.55..7.62 rows=1 width=112) (never executed)

30. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.55..6.60 rows=1 width=8) (never executed)

31. 0.000 0.000 ↓ 0.0 0

Index Scan using operador_uk1 on operador ope_1 (cost=0.28..4.30 rows=1 width=9) (never executed)

  • Index Cond: ((seq_operador)::text = '0193'::text)
  • Filter: (id_visao_emp_todos = 'N'::bpchar)
32. 0.000 0.000 ↓ 0.0 0

Index Only Scan using operador_pessoa_empresa_pk on operador_pessoa_empresa opepesemp (cost=0.28..2.29 rows=1 width=17) (never executed)

  • Index Cond: ((cd_operador = (ope_1.cd_operador)::text) AND (cd_empresa = 1))
  • Heap Fetches: 0
33. 0.000 0.000 ↓ 0.0 0

Seq Scan on pessoa_empresa pesemp_1 (cost=0.00..1.01 rows=1 width=112) (never executed)

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

Nested Loop (cost=0.28..5.32 rows=1 width=112) (never executed)

35. 0.000 0.000 ↓ 0.0 0

Index Scan using operador_uk1 on operador ope_2 (cost=0.28..4.30 rows=1 width=0) (never executed)

  • Index Cond: ((seq_operador)::text = '0193'::text)
  • Filter: (id_visao_emp_todos = 'S'::bpchar)
36. 0.000 0.000 ↓ 0.0 0

Seq Scan on pessoa_empresa pesemp_2 (cost=0.00..1.01 rows=1 width=112) (never executed)

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

Result (cost=0.00..1.01 rows=1 width=112) (never executed)

  • One-Time Filter: false
38. 0.000 0.000 ↓ 0.0 0

Seq Scan on pessoa_empresa pesemp_3 (cost=0.00..1.01 rows=1 width=112) (never executed)

39. 0.014 0.409 ↑ 3.0 64 1

Nested Loop (cost=14.36..26.69 rows=192 width=211) (actual time=0.234..0.409 rows=64 loops=1)

40. 0.139 0.139 ↑ 1.0 64 1

Seq Scan on pessoa_filial pesfil_1 (cost=0.00..5.81 rows=64 width=211) (actual time=0.015..0.139 rows=64 loops=1)

  • Filter: (cd_empresa = 1)
  • Rows Removed by Filter: 1
41. 0.045 0.256 ↑ 3.0 1 64

Materialize (cost=14.36..18.48 rows=3 width=8) (actual time=0.003..0.004 rows=1 loops=64)

42. 0.007 0.211 ↑ 3.0 1 1

Nested Loop (cost=14.36..18.47 rows=3 width=8) (actual time=0.209..0.211 rows=1 loops=1)

43. 0.017 0.017 ↑ 1.0 1 1

Index Scan using operador_uk1 on operador ope_3 (cost=0.28..4.30 rows=1 width=0) (actual time=0.016..0.017 rows=1 loops=1)

  • Index Cond: ((seq_operador)::text = '0193'::text)
  • Filter: (id_visao_filial_todos = 'S'::bpchar)
44. 0.021 0.187 ↑ 3.0 1 1

HashAggregate (cost=14.09..14.12 rows=3 width=112) (actual time=0.186..0.187 rows=1 loops=1)

  • Group Key: pesemp_4.cd_empresa, pesemp_4.cd_pessoa, pesemp_4.cd_regime_fiscal, pesemp_4.dt_baixa, pesemp_4.dt_arq_atos_const, pesemp_4.dt_arq_conv_simp_empr, pesemp_4.coef_acresc_venda_ncoop, pesemp_4.id_cooperativa, pesemp_4.id_origem_tribut, pesemp_4.id_controla_fci, pesemp_4.nr_max_itens_nfe, pesemp_4.id_valida_cest_fat, pesemp_4.id_consiste_ncm_xml, pesemp_4.nr_dias_rev_cad_cli_ven
45. 0.001 0.166 ↑ 3.0 1 1

Append (cost=0.55..13.98 rows=3 width=112) (actual time=0.141..0.166 rows=1 loops=1)

46. 0.005 0.144 ↑ 1.0 1 1

Nested Loop (cost=0.55..7.62 rows=1 width=112) (actual time=0.140..0.144 rows=1 loops=1)

47. 0.011 0.099 ↑ 1.0 1 1

Nested Loop (cost=0.55..6.60 rows=1 width=8) (actual time=0.097..0.099 rows=1 loops=1)

48. 0.016 0.016 ↑ 1.0 1 1

Index Scan using operador_uk1 on operador ope_4 (cost=0.28..4.30 rows=1 width=9) (actual time=0.016..0.016 rows=1 loops=1)

  • Index Cond: ((seq_operador)::text = '0193'::text)
  • Filter: (id_visao_emp_todos = 'N'::bpchar)
49. 0.072 0.072 ↑ 1.0 1 1

Index Only Scan using operador_pessoa_empresa_pk on operador_pessoa_empresa opepesemp_1 (cost=0.28..2.29 rows=1 width=17) (actual time=0.071..0.072 rows=1 loops=1)

  • Index Cond: ((cd_operador = (ope_4.cd_operador)::text) AND (cd_empresa = 1))
  • Heap Fetches: 0
50. 0.040 0.040 ↑ 1.0 1 1

Seq Scan on pessoa_empresa pesemp_4 (cost=0.00..1.01 rows=1 width=112) (actual time=0.040..0.040 rows=1 loops=1)

  • Filter: (cd_empresa = 1)
  • Rows Removed by Filter: 1
51. 0.000 0.020 ↓ 0.0 0 1

Nested Loop (cost=0.28..5.32 rows=1 width=112) (actual time=0.020..0.020 rows=0 loops=1)

52. 0.020 0.020 ↓ 0.0 0 1

Index Scan using operador_uk1 on operador ope_5 (cost=0.28..4.30 rows=1 width=0) (actual time=0.020..0.020 rows=0 loops=1)

  • Index Cond: ((seq_operador)::text = '0193'::text)
  • Filter: (id_visao_emp_todos = 'S'::bpchar)
  • Rows Removed by Filter: 1
53. 0.000 0.000 ↓ 0.0 0

Seq Scan on pessoa_empresa pesemp_5 (cost=0.00..1.01 rows=1 width=112) (never executed)

  • Filter: (cd_empresa = 1)
54. 0.001 0.001 ↓ 0.0 0 1

Result (cost=0.00..1.01 rows=1 width=112) (actual time=0.001..0.001 rows=0 loops=1)

  • One-Time Filter: false
55. 0.000 0.000 ↓ 0.0 0

Seq Scan on pessoa_empresa pesemp_6 (cost=0.00..1.01 rows=1 width=112) (never executed)

56. 0.001 0.001 ↓ 0.0 0 1

Result (cost=0.00..5.65 rows=1 width=211) (actual time=0.001..0.001 rows=0 loops=1)

  • One-Time Filter: false
57. 0.000 0.000 ↓ 0.0 0

Seq Scan on pessoa_filial pesfil_2 (cost=0.00..5.65 rows=1 width=211) (never executed)

58. 1.088 1.088 ↑ 1.0 1 64

Index Only Scan using pessoa_atividade_pk on pessoa_atividade pesati (cost=0.41..2.87 rows=1 width=15) (actual time=0.017..0.017 rows=1 loops=64)

  • Index Cond: ((cd_pessoa = pesfil.cd_pessoa) AND (id_atividade = (pesfil.id_atividade)::text))
  • Heap Fetches: 63
59. 512.580 512.580 ↓ 0.0 0 42,715

Index Scan using pat_bem_pk on pat_bem patbem (cost=0.29..0.34 rows=1 width=20) (actual time=0.012..0.012 rows=0 loops=42,715)

  • Index Cond: ((cd_empresa = 1) AND (cd_bem = patbemloc.cd_bem))
  • Filter: (((cd_pat_grupo)::text = '003'::text) AND ((dt_baixa > to_date('2018-12-31'::text, 'yyyy-MM-dd'::text)) OR (id_situacao <> ALL ('{B,L,C}'::bpchar[]))))
  • Rows Removed by Filter: 1
60. 97.122 97.122 ↑ 1.0 1 16,187

Index Only Scan using pat_grupo_pk on pat_grupo patgru (cost=0.14..2.16 rows=1 width=12) (actual time=0.006..0.006 rows=1 loops=16,187)

  • Index Cond: ((cd_empresa = 1) AND (cd_pat_grupo = '003'::text))
  • Heap Fetches: 0
61. 113.309 113.309 ↑ 1.0 1 16,187

Index Scan using pessoa_pk on pessoa pes (cost=0.29..0.38 rows=1 width=29) (actual time=0.007..0.007 rows=1 loops=16,187)

  • Index Cond: (cd_pessoa = pesati.cd_pessoa)
62. 2,816.538 2,816.538 ↑ 1.2 46 16,187

Index Scan using pat_bem_mov_idx2 on pat_bem_mov patbemmov (cost=0.43..2.13 rows=53 width=53) (actual time=0.018..0.174 rows=46 loops=16,187)

  • Index Cond: ((cd_empresa = 1) AND (cd_bem = patbemloc.cd_bem))
  • Filter: (dt_movimento <= to_date('2018-12-31'::text, 'yyyy-MM-dd'::text))
  • Rows Removed by Filter: 0
63. 3,738.575 3,738.575 ↓ 0.0 0 747,715

Index Only Scan using processo_canc_pk on processo_canc procan (cost=0.42..0.44 rows=1 width=24) (actual time=0.005..0.005 rows=0 loops=747,715)

  • Index Cond: ((cd_empresa = patbemmov.cd_empresa) AND (cd_empresa = 1) AND (cd_base = patbemmov.cd_base) AND (seq_processo = patbemmov.seq_processo))
  • Heap Fetches: 124
64. 1,494.542 1,494.542 ↑ 1.0 1 747,271

Index Scan using operacao_patrimonio_pk on operacao_patrimonio opepat (cost=0.14..0.16 rows=1 width=20) (actual time=0.001..0.002 rows=1 loops=747,271)

  • Index Cond: (cd_operacao = patbemmov.cd_operacao)