explain.depesz.com

PostgreSQL's explain analyze made readable

Result: R1VN : Diferimento x Valor Bruto x Pagamento x Desconto - Quantidade de Descontos Por Cupom

Settings
# exclusive inclusive rows x rows loops node
1. 22.696 1,897.809 ↓ 1.2 14,707 1

Sort (cost=12,803.74..12,833.77 rows=12,012 width=116) (actual time=1,886.771..1,897.809 rows=14,707 loops=1)

  • Sort Key: (sum(des.valor)) DESC
  • Sort Method: quicksort Memory: 1541kB
  • Buffers: shared hit=148214 read=30, temp read=286 written=287
2. 123.791 1,875.113 ↓ 1.2 14,707 1

GroupAggregate (cost=10,941.62..11,869.67 rows=12,012 width=116) (actual time=1,728.688..1,875.113 rows=14,707 loops=1)

  • Group Key: des.cupom
  • Buffers: shared hit=148214 read=30, temp read=286 written=287
3. 739.087 1,751.322 ↓ 1.1 53,271 1

Sort (cost=10,941.62..11,061.26 rows=47,856 width=29) (actual time=1,728.666..1,751.322 rows=53,271 loops=1)

  • Sort Key: des.cupom
  • Sort Method: external merge Disk: 2288kB
  • Buffers: shared hit=148214 read=30, temp read=286 written=287
4. 246.866 1,012.235 ↓ 1.1 53,271 1

Hash Join (cost=5,289.59..7,221.68 rows=47,856 width=29) (actual time=713.097..1,012.235 rows=53,271 loops=1)

  • Buffers: shared hit=148214 read=30
5. 52.355 52.355 ↓ 1.0 65,542 1

Seq Scan on pedido_oferta pofer (cost=0..1,072.63 rows=65,463 width=16) (actual time=0.007..52.355 rows=65,542 loops=1)

  • Buffers: shared hit=418
6. 113.429 713.014 ↓ 1.0 48,843 1

Hash (cost=4,691.39..4,691.39 rows=47,856 width=29) (actual time=713.013..713.014 rows=48,843 loops=1)

  • Buffers: shared hit=147796 read=30
7. 76.935 599.585 ↓ 1.0 48,843 1

Nested Loop (cost=1,662.32..4,691.39 rows=47,856 width=29) (actual time=112.731..599.585 rows=48,843 loops=1)

  • Buffers: shared hit=147796 read=30
8. 136.967 278.435 ↓ 530.9 48,843 1

Hash Join (cost=1,662.02..4,654.3 rows=92 width=41) (actual time=112.704..278.435 rows=48,843 loops=1)

  • Buffers: shared hit=1091
9. 28.960 28.960 ↓ 1.0 75,308 1

Seq Scan on pagamento pag (cost=0..1,487.12 rows=75,212 width=12) (actual time=0.008..28.96 rows=75,308 loops=1)

  • Buffers: shared hit=735
10. 45.475 112.508 ↑ 1.0 46,448 1

Hash (cost=964.76..964.76 rows=46,484 width=29) (actual time=112.508..112.508 rows=46,448 loops=1)

  • Buffers: shared hit=356
11. 55.918 67.033 ↑ 1.0 46,448 1

Hash Join (cost=21.93..964.76 rows=46,484 width=29) (actual time=0.027..67.033 rows=46,448 loops=1)

  • Buffers: shared hit=356
12. 11.106 11.106 ↑ 1.0 46,448 1

Seq Scan on desconto des (cost=0..819.84 rows=46,484 width=25) (actual time=0.005..11.106 rows=46,448 loops=1)

  • Buffers: shared hit=355
13. 0.005 0.009 ↑ 265.0 2 1

Hash (cost=15.3..15.3 rows=530 width=4) (actual time=0.009..0.009 rows=2 loops=1)

  • Buffers: shared hit=1
14. 0.004 0.004 ↑ 265.0 2 1

Seq Scan on instituicao inst (cost=0..15.3 rows=530 width=4) (actual time=0.003..0.004 rows=2 loops=1)

  • Buffers: shared hit=1
15. 244.215 244.215 ↑ 1.0 1 48,843

Index Scan using pk_pedido on pedido ped (cost=0.29..0.39 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=48,843)

  • Index Cond: ((ped.codigo = pag.codigo_pedido) AND (ped.instituicao = pag.instituicao))
  • Buffers: shared hit=146705 read=30
Planning time : 1.876 ms
Execution time : 1,915.215 ms