explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 3gaK

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Sort (cost=19,555,617.81..19,555,617.88 rows=30 width=16) (actual rows= loops=)

  • Sort Key: (max(CASE WHEN (t0.relay = 0) THEN t0.data_hora_ini ELSE NULL::timestamp without time zone END))
2. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=19,274,768.63..19,555,617.07 rows=30 width=16) (actual rows= loops=)

3. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=19,274,768.63..19,555,179.45 rows=34,986 width=16) (actual rows= loops=)

  • Merge Cond: (l.id_loja = t0.id_loja)
4. 0.000 0.000 ↓ 0.0

Sort (cost=2.04..2.11 rows=30 width=4) (actual rows= loops=)

  • Sort Key: l.id_loja
5. 0.000 0.000 ↓ 0.0

Seq Scan on loja l (cost=0.00..1.30 rows=30 width=4) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Materialize (cost=19,274,766.59..19,554,739.94 rows=34,986 width=16) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Subquery Scan on t0 (cost=19,274,766.59..19,554,652.47 rows=34,986 width=16) (actual rows= loops=)

  • Filter: (t0.rank = 1)
8. 0.000 0.000 ↓ 0.0

WindowAgg (cost=19,274,766.59..19,467,188.13 rows=6,997,147 width=553) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Sort (cost=19,274,766.59..19,292,259.46 rows=6,997,147 width=553) (actual rows= loops=)

  • Sort Key: s.id_loja, (CASE WHEN ((se.entidade)::text = 'RELAY'::text) THEN 1 ELSE 0 END), s.data_hora_ini, se.entidade
10. 0.000 0.000 ↓ 0.0

Hash Join (cost=253,945.12..9,749,881.71 rows=6,997,147 width=553) (actual rows= loops=)

  • Hash Cond: (((se.uuid)::text = (s.uuid)::text) AND (se.id_loja = s.id_loja))
11. 0.000 0.000 ↓ 0.0

Seq Scan on sync_entidade se (cost=0.00..4,057,580.56 rows=176,040,256 width=56) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Hash (cost=49,497.85..49,497.85 rows=2,316,885 width=575) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Seq Scan on sync s (cost=0.00..49,497.85 rows=2,316,885 width=575) (actual rows= loops=)