explain.depesz.com

PostgreSQL's explain analyze made readable

Result: DaK6 : Optimization for: plan #5dS

Settings

Optimization path:

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

Sort (cost=61.00..61.01 rows=1 width=158) (actual rows= loops=)

  • Sort Key: (CASE WHEN ((conf.company_id IS NULL) AND (conf.device_id IS NULL)) THEN 1 WHEN (conf.device_id IS NULL) THEN 2 ELSE 3 END) DESC
2.          

Initplan (forSort)

3. 0.000 0.000 ↓ 0.0

Index Scan using ix_devices_device_id on devices (cost=0.15..8.17 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (device_id = 123)
4. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=19.45..52.82 rows=1 width=158) (actual rows= loops=)

  • Hash Cond: (d.id = conf.device_id)
  • Filter: ((d.device_id = 123) OR (conf.company_id = $0) OR ((conf.company_id IS NULL) AND (conf.device_id IS NULL)))
5. 0.000 0.000 ↓ 0.0

Seq Scan on devices d (cost=0.00..28.50 rows=1,850 width=12) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Hash (cost=14.20..14.20 rows=420 width=162) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Seq Scan on configuration conf (cost=0.00..14.20 rows=420 width=162) (actual rows= loops=)