explain.depesz.com

PostgreSQL's explain analyze made readable

Result: HwjM

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.001 89.737 ↑ 1.0 1 1

Limit (cost=17,859.99..17,859.99 rows=1 width=12) (actual time=89.737..89.737 rows=1 loops=1)

2. 0.019 89.736 ↑ 277.0 1 1

Sort (cost=17,859.99..17,860.68 rows=277 width=12) (actual time=89.736..89.736 rows=1 loops=1)

  • Sort Key: (count(selo.tx_numero_selo)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
3. 0.000 89.717 ↑ 2.3 119 1

Finalize GroupAggregate (cost=17,822.60..17,858.61 rows=277 width=12) (actual time=89.583..89.717 rows=119 loops=1)

  • Group Key: selo.id_cartorio
4. 6.286 93.345 ↑ 1.3 206 1

Gather Merge (cost=17,822.60..17,854.45 rows=277 width=12) (actual time=89.579..93.345 rows=206 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
5. 0.046 87.059 ↑ 2.7 103 2 / 2

Sort (cost=16,822.59..16,823.28 rows=277 width=12) (actual time=87.052..87.059 rows=103 loops=2)

  • Sort Key: selo.id_cartorio
  • Sort Method: quicksort Memory: 29kB
  • Worker 0: Sort Method: quicksort Memory: 29kB
6. 1.889 87.013 ↑ 2.7 103 2 / 2

Partial HashAggregate (cost=16,808.58..16,811.35 rows=277 width=12) (actual time=86.995..87.013 rows=103 loops=2)

  • Group Key: selo.id_cartorio
7. 3.033 85.124 ↓ 1.5 5,216 2 / 2

Nested Loop Left Join (cost=2,917.00..16,791.12 rows=3,491 width=33) (actual time=11.734..85.124 rows=5,216 loops=2)

  • Filter: ((selo_compensado.cs_situacao_compensado IS NULL) OR (selo_compensado.automatico AND (selo_compensado.cs_situacao_compensado <> ALL ('{0,1}'::integer[]))))
  • Rows Removed by Filter: 5,378
8. 9.210 60.904 ↓ 1.4 10,594 2 / 2

Parallel Hash Join (cost=2,916.58..11,461.55 rows=7,442 width=37) (actual time=11.726..60.904 rows=10,594 loops=2)

  • Hash Cond: (selo.id_selo_analisado = selo_analisado.id_selo_analisado)
9. 40.785 40.785 ↑ 1.1 23,024 2 / 2

Parallel Index Scan using selo_cs_isento_idx on selo (cost=0.43..8,476.22 rows=26,354 width=41) (actual time=0.639..40.785 rows=23,024 loops=2)

  • Index Cond: (cs_isento = true)
  • Filter: (cs_isento AND (NOT cs_gratuito) AND (cs_situacao_selo = 0))
  • Rows Removed by Filter: 1,267
10. 2.450 10.909 ↑ 1.2 10,730 2 / 2

Parallel Hash (cost=2,759.34..2,759.34 rows=12,545 width=4) (actual time=10.909..10.909 rows=10,730 loops=2)

  • Buckets: 32,768 Batches: 1 Memory Usage: 1,152kB
11. 8.459 8.459 ↑ 1.2 10,730 2 / 2

Parallel Seq Scan on selo_analisado (cost=0.00..2,759.34 rows=12,545 width=4) (actual time=0.033..8.459 rows=10,730 loops=2)

  • Filter: (cs_situacao_isento = 1)
  • Rows Removed by Filter: 27,032
12. 21.187 21.187 ↑ 1.0 1 21,187 / 2

Index Scan using selo_compensado_pkey on selo_compensado (cost=0.42..0.70 rows=1 width=9) (actual time=0.002..0.002 rows=1 loops=21,187)

  • Index Cond: (id_selo_compensado = selo.id_selo_compensado)