explain.depesz.com

PostgreSQL's explain analyze made readable

Result: xKmt

Settings
# exclusive inclusive rows x rows loops node
1. 2.848 3,514.003 ↓ 1,000.0 1,000 1

Limit (cost=680.21..700.93 rows=1 width=188) (actual time=1,672.543..3,514.003 rows=1,000 loops=1)

2. 22.440 3,511.155 ↓ 1,000.0 1,000 1

Nested Loop Left Join (cost=680.21..700.93 rows=1 width=188) (actual time=1,672.540..3,511.155 rows=1,000 loops=1)

  • Join Filter: (pn.id_cliente_plano = cp.id_cliente_plano)
  • Filter: (((cp.status_plano IS NOT NULL) AND (cp.status_plano = 'A'::enum_status) AND ((pn.forma_pagamento = 'F'::enum_forma_pagamento) OR (pn.status = 'A'::enum_status_pagamento))) OR (cp.status_plano IS NULL))
3. 262.757 3,469.715 ↓ 1,000.0 1,000 1

Nested Loop (cost=680.21..697.43 rows=1 width=200) (actual time=1,672.369..3,469.715 rows=1,000 loops=1)

  • Join Filter: (((cl.id_conta IS NOT NULL) AND (cl.id_conta = c.id_conta) AND (jc.id_jornal = 9) AND (jc.sit_cad = 'A'::enum_status)) OR (cl.id_conta IS NULL))
4. 9.364 2,979.542 ↓ 917.0 917 1

Nested Loop (cost=675.94..690.00 rows=1 width=208) (actual time=1,671.918..2,979.542 rows=917 loops=1)

5. 294.604 2,905.071 ↓ 917.0 917 1

Nested Loop (cost=675.94..684.42 rows=1 width=208) (actual time=1,671.849..2,905.071 rows=917 loops=1)

  • Join Filter: ((npj.id_jornal = cj.id_jornal) OR np.todos_jornais)
6. 235.403 2,073.683 ↓ 33,549.0 33,549 1

Merge Left Join (cost=675.94..676.13 rows=1 width=216) (actual time=1,671.610..2,073.683 rows=33,549 loops=1)

  • Merge Cond: (cl.id_cliente = cp.id_cliente)
7. 558.775 1,838.043 ↓ 33,549.0 33,549 1

Sort (cost=673.78..673.79 rows=1 width=204) (actual time=1,671.361..1,838.043 rows=33,549 loops=1)

  • Sort Key: cl.id_cliente
  • Sort Method: external merge Disk: 4728kB
8. 365.399 1,279.268 ↓ 54,414.0 54,414 1

Hash Right Join (cost=422.25..673.77 rows=1 width=204) (actual time=903.215..1,279.268 rows=54,414 loops=1)

  • Hash Cond: (npj.id_nome_pesquisa = np.id_nome_pesquisa)
9. 12.902 12.902 ↑ 1.0 13,128 1

Seq Scan on nome_pesquisa_jornal npj (cost=0.00..202.28 rows=13,128 width=16) (actual time=0.007..12.902 rows=13,128 loops=1)

10. 232.014 900.967 ↓ 54,302.0 54,302 1

Hash (cost=422.24..422.24 rows=1 width=196) (actual time=900.967..900.967 rows=54,302 loops=1)

  • Buckets: 1024 Batches: 8 (originally 1) Memory Usage: 1025kB
11. 352.357 668.953 ↓ 54,302.0 54,302 1

Nested Loop (cost=16.68..422.24 rows=1 width=196) (actual time=1.852..668.953 rows=54,302 loops=1)

12. 39.880 59.796 ↓ 1,605.0 1,605 1

Nested Loop (cost=0.00..74.34 rows=1 width=32) (actual time=1.764..59.796 rows=1,605 loops=1)

  • Join Filter: (cl.id_conta = c.id_conta)
13. 0.044 0.044 ↓ 6.0 6 1

Seq Scan on conta c (cost=0.00..1.09 rows=1 width=8) (actual time=0.016..0.044 rows=6 loops=1)

  • Filter: (sit_cad = 'A'::enum_status_conta)
14. 19.872 19.872 ↓ 189.1 2,269 6

Seq Scan on cliente cl (cost=0.00..73.10 rows=12 width=24) (actual time=0.004..3.312 rows=2,269 loops=6)

  • Filter: (sit_cad = 'A'::enum_status_cliente)
15. 221.490 256.800 ↑ 9.3 34 1,605

Bitmap Heap Scan on nome_pesquisa np (cost=16.68..343.95 rows=316 width=164) (actual time=0.046..0.160 rows=34 loops=1,605)

  • Recheck Cond: (id_cliente = cl.id_cliente)
  • Filter: ((NOT oab) AND (sit_cad = 'A'::enum_status))
16. 35.310 35.310 ↑ 8.2 77 1,605

Bitmap Index Scan on nome_pesquisa_id_cliente_idx (cost=0.00..16.68 rows=632 width=0) (actual time=0.022..0.022 rows=77 loops=1,605)

  • Index Cond: (id_cliente = cl.id_cliente)
17. 0.155 0.237 ↑ 33.0 1 1

Sort (cost=2.16..2.24 rows=33 width=20) (actual time=0.237..0.237 rows=1 loops=1)

  • Sort Key: cp.id_cliente
  • Sort Method: quicksort Memory: 17kB
18. 0.082 0.082 ↑ 3.7 9 1

Seq Scan on cliente_plano cp (cost=0.00..1.33 rows=33 width=20) (actual time=0.071..0.082 rows=9 loops=1)

19. 536.784 536.784 ↓ 0.0 0 33,549

Index Scan using cliente_jornal_id_jornal_idx on cliente_jornal cj (cost=0.00..8.28 rows=1 width=16) (actual time=0.015..0.016 rows=0 loops=33,549)

  • Index Cond: ((id_jornal = 9) AND (id_cliente = cl.id_cliente))
  • Filter: (sit_cad = 'A'::enum_status)
20. 65.107 65.107 ↑ 1.0 1 917

Seq Scan on jornal j (cost=0.00..5.58 rows=1 width=8) (actual time=0.020..0.071 rows=1 loops=917)

  • Filter: ((id_jornal = 9) AND (sit_cad = 'A'::bpchar))
21. 202.657 227.416 ↓ 42.0 84 917

Bitmap Heap Scan on jornal_conta jc (cost=4.27..7.39 rows=2 width=20) (actual time=0.037..0.248 rows=84 loops=917)

  • Recheck Cond: (id_conta = c.id_conta)
22. 24.759 24.759 ↓ 42.0 84 917

Bitmap Index Scan on jornal_conta_id_conta_idx (cost=0.00..4.27 rows=2 width=0) (actual time=0.027..0.027 rows=84 loops=917)

  • Index Cond: (id_conta = c.id_conta)
23. 19.000 19.000 ↑ 5.6 9 1,000

Seq Scan on pagamento_plano pn (cost=0.00..2.50 rows=50 width=16) (actual time=0.005..0.019 rows=9 loops=1,000)