explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 8xkm

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↑ 109.0 1 1

Subquery Scan on documentoi0_ (cost=67,329.92..178,233.64 rows=109 width=635) (actual rows=1 loops=1)

  • Buffers: shared hit=23699, temp written=12800
2. 0.000 0.000 ↑ 109.0 1 1

Nested Loop Left Join (cost=67,329.92..178,232.55 rows=109 width=635) (actual rows=1 loops=1)

  • Join Filter: (pte.id_processo_documento = (doc.id_processo_documento)::integer)
  • Buffers: shared hit=23699, temp written=12800
3.          

CTE grau

4. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_parametro_in01 on tb_parametro (cost=0.28..4.29 rows=1 width=15) (actual rows=1 loops=1)

  • Index Cond: ((nm_variavel)::text = 'aplicacaoSistema'::text)
  • Buffers: shared hit=3
5.          

CTE tribunal

6. 0.000 0.000 ↑ 1.0 1 1

Seq Scan on tb_tribunal (cost=0.00..1.01 rows=1 width=14) (actual rows=1 loops=1)

  • Buffers: shared hit=1
7.          

CTE processoassuntos

8. 0.000 0.000 ↓ 1.0 4,369,140 1

Seq Scan on tb_processo_assunto (cost=0.00..67,322.01 rows=4,366,001 width=14) (actual rows=4,369,140 loops=1)

  • Buffers: shared hit=23662
9.          

Initplan (forNested Loop Left Join)

10. 0.000 0.000 ↑ 1.0 1 1

CTE Scan on tribunal (cost=0.00..0.02 rows=1 width=19) (actual rows=1 loops=1)

  • Buffers: shared hit=1
11. 0.000 0.000 ↑ 1.0 1 1

CTE Scan on grau (cost=0.00..0.02 rows=1 width=32) (actual rows=1 loops=1)

  • Buffers: shared hit=3
12. 0.000 0.000 ↑ 1.0 1 1

CTE Scan on grau grau_1 (cost=0.00..0.02 rows=1 width=32) (actual rows=1 loops=1)

13. 0.000 0.000 ↑ 109.0 1 1

Nested Loop (cost=2.11..109,892.20 rows=109 width=547) (actual rows=1 loops=1)

  • Buffers: shared hit=23690, temp written=12800
14. 0.000 0.000 ↑ 1.0 1 1

Nested Loop (cost=1.40..13.49 rows=1 width=298) (actual rows=1 loops=1)

  • Buffers: shared hit=18
15. 0.000 0.000 ↑ 1.0 1 1

Nested Loop (cost=1.13..9.19 rows=1 width=264) (actual rows=1 loops=1)

  • Buffers: shared hit=15
16. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_processo_documento_in04 on tb_processo_documento doc (cost=0.56..4.60 rows=1 width=94) (actual rows=1 loops=1)

  • Index Cond: ((id_processo_documento)::integer = $2)
  • Filter: ((dt_juntada IS NOT NULL) AND ((id_processo)::integer = $1) AND ((in_ativo)::bpchar = 'S'::bpchar) AND ((in_documento_sigiloso)::bpchar = 'N'::bpchar) AND (($6 = '3'::text) OR ((ds_instancia)::text = '3'::text) OR ((ds_instancia)::text = $7)))
  • Buffers: shared hit=8
17. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_processo_documento_bin_pk on tb_processo_documento_bin docbin (cost=0.56..4.58 rows=1 width=170) (actual rows=1 loops=1)

  • Index Cond: ((id_processo_documento_bin)::integer = (doc.id_processo_documento_bin)::integer)
  • Buffers: shared hit=7
18. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_tipo_processo_documento_pk on tb_tipo_processo_documento tpd (cost=0.28..4.29 rows=1 width=38) (actual rows=1 loops=1)

  • Index Cond: ((id_tipo_processo_documento)::integer = (doc.id_tipo_processo_documento)::integer)
  • Buffers: shared hit=3
19. 0.000 0.000 ↑ 109.0 1 1

Nested Loop Left Join (cost=0.71..109,877.62 rows=109 width=253) (actual rows=1 loops=1)

  • Buffers: shared hit=23672, temp written=12800
20. 0.000 0.000 ↑ 109.0 1 1

Nested Loop Left Join (cost=0.42..109,638.10 rows=109 width=111) (actual rows=1 loops=1)

  • Join Filter: ((ojc.id_orgao_julgador_colegiado)::integer = (ptrf.id_orgao_julgador_colegiado)::integer)
  • Buffers: shared hit=23669, temp written=12800
21. 0.000 0.000 ↑ 109.0 1 1

Nested Loop Left Join (cost=0.42..109,364.50 rows=109 width=79) (actual rows=1 loops=1)

  • Join Filter: ((ptrf.id_orgao_julgador)::integer = (oj.id_orgao_julgador)::integer)
  • Rows Removed by Join Filter: 124
  • Buffers: shared hit=23669, temp written=12800
22. 0.000 0.000 ↑ 109.0 1 1

Nested Loop (cost=0.42..109,155.56 rows=109 width=43) (actual rows=1 loops=1)

  • Buffers: shared hit=23666, temp written=12800
23. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_processo_trf_pk on tb_processo_trf ptrf (cost=0.42..4.45 rows=1 width=39) (actual rows=1 loops=1)

  • Index Cond: ((id_processo_trf)::integer = $1)
  • Filter: ((cd_processo_status = 'D'::bpchar) AND ((in_segredo_justica)::bpchar = 'N'::bpchar))
  • Buffers: shared hit=4
24. 0.000 0.000 ↑ 109.0 1 1

CTE Scan on processoassuntos pa (cost=0.00..109,150.03 rows=109 width=8) (actual rows=1 loops=1)

  • Filter: (((id_processo_trf)::integer = $1) AND (in_assunto_principal = 'S'::bpchar))
  • Rows Removed by Filter: 4369139
  • Buffers: shared hit=23662, temp written=12800
25. 0.000 0.000 ↑ 1.0 125 1

Materialize (cost=0.00..4.88 rows=125 width=40) (actual rows=125 loops=1)

  • Buffers: shared hit=3
26. 0.000 0.000 ↑ 1.0 125 1

Seq Scan on tb_orgao_julgador oj (cost=0.00..4.25 rows=125 width=40) (actual rows=125 loops=1)

  • Buffers: shared hit=3
27. 0.000 0.000 ↓ 0.0 0 1

Materialize (cost=0.00..12.40 rows=160 width=36) (actual rows=0 loops=1)

28. 0.000 0.000 ↓ 0.0 0 1

Seq Scan on tb_orgao_julgador_colgiado ojc (cost=0.00..11.60 rows=160 width=36) (actual rows=0 loops=1)

29. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_assunto_trf_pk on tb_assunto_trf a (cost=0.28..2.19 rows=1 width=150) (actual rows=1 loops=1)

  • Index Cond: (id_assunto_trf = (pa.id_assunto_trf)::integer)
  • Buffers: shared hit=3
30. 0.000 0.000 ↓ 0.0 0 1

Materialize (cost=0.43..4.46 rows=1 width=6) (actual rows=0 loops=1)

  • Buffers: shared hit=3
31. 0.000 0.000 ↓ 0.0 0 1

Index Scan using tb_pte_status_documento_indexado_pk on tb_pte_status_documento_indexado pte (cost=0.43..4.45 rows=1 width=6) (actual rows=0 loops=1)

  • Index Cond: (id_processo_documento = $2)
  • Buffers: shared hit=3
32.          

SubPlan (forNested Loop Left Join)

33. 0.000 0.000 ↑ 1.0 1 1

Aggregate (cost=4.59..4.60 rows=1 width=32) (actual rows=1 loops=1)

  • Buffers: shared hit=5
34. 0.000 0.000 ↑ 1.0 1 1

Index Scan using tb_proc_dc_bin_pess_assin_in01 on tb_proc_doc_bin_pess_assin assin (cost=0.56..4.58 rows=1 width=23) (actual rows=1 loops=1)

  • Index Cond: ((id_processo_documento_bin)::integer = (docbin.id_processo_documento_bin)::integer)
  • Buffers: shared hit=5
35. 0.000 0.000 ↓ 0.0 0 1

Index Scan using tb_processo_documento_in04 on tb_processo_documento doc2 (cost=0.56..4.58 rows=1 width=36) (actual rows=0 loops=1)

  • Index Cond: ((id_processo_documento)::integer = (doc.id_documento_principal)::integer)