explain.depesz.com

PostgreSQL's explain analyze made readable

Result: nlcS

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

Unique (cost=38,076.25..38,508.75 rows=57,667 width=617) (actual time=0.123..0.123 rows=0 loops=1)

2. 0.023 0.123 ↓ 0.0 0 1

Sort (cost=38,076.25..38,220.41 rows=57,667 width=617) (actual time=0.123..0.123 rows=0 loops=1)

  • Sort Key: s.id, h.sensor_id, h.received_at DESC
  • Sort Method: quicksort Memory: 25kB
3. 0.000 0.100 ↓ 0.0 0 1

Hash Left Join (cost=105.78..17,549.10 rows=57,667 width=617) (actual time=0.100..0.100 rows=0 loops=1)

  • Hash Cond: (ls.line_id = l.id)
4. 0.001 0.100 ↓ 0.0 0 1

Hash Left Join (cost=86.24..16,800.44 rows=57,667 width=598) (actual time=0.099..0.100 rows=0 loops=1)

  • Hash Cond: (s.id = ls.sensor_id)
  • Join Filter: (ls.connected @> h.received_at)
5. 0.000 0.099 ↓ 0.0 0 1

Nested Loop Left Join (cost=61.89..15,922.97 rows=57,667 width=594) (actual time=0.099..0.099 rows=0 loops=1)

  • Join Filter: s.enumerated
6. 0.012 0.099 ↓ 0.0 0 1

Hash Join (cost=61.46..183.38 rows=43 width=578) (actual time=0.099..0.099 rows=0 loops=1)

  • Hash Cond: (s.bru_id = b.id)
7. 0.008 0.008 ↑ 1,128.0 1 1

Seq Scan on sensors s (cost=0.00..117.28 rows=1,128 width=9) (actual time=0.008..0.008 rows=1 loops=1)

8. 0.000 0.079 ↓ 0.0 0 1

Hash (cost=61.32..61.32 rows=11 width=577) (actual time=0.079..0.079 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
9. 0.012 0.079 ↓ 0.0 0 1

Hash Join (cost=49.08..61.32 rows=11 width=577) (actual time=0.079..0.079 rows=0 loops=1)

  • Hash Cond: (b.gateway_id = g.id)
10. 0.003 0.003 ↑ 300.0 1 1

Seq Scan on brus b (cost=0.00..11.00 rows=300 width=8) (actual time=0.003..0.003 rows=1 loops=1)

11. 0.000 0.064 ↓ 0.0 0 1

Hash (cost=49.04..49.04 rows=3 width=577) (actual time=0.064..0.064 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
12. 0.012 0.064 ↓ 0.0 0 1

Hash Join (cost=36.98..49.04 rows=3 width=577) (actual time=0.064..0.064 rows=0 loops=1)

  • Hash Cond: (g.establishment_id = st.establishment_id)
13. 0.002 0.002 ↑ 75.0 1 1

Seq Scan on gateways g (cost=0.00..11.75 rows=75 width=8) (actual time=0.002..0.002 rows=1 loops=1)

14. 0.000 0.050 ↓ 0.0 0 1

Hash (cost=36.97..36.97 rows=1 width=569) (actual time=0.050..0.050 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
15. 0.001 0.050 ↓ 0.0 0 1

Merge Left Join (cost=33.95..36.97 rows=1 width=569) (actual time=0.050..0.050 rows=0 loops=1)

  • Merge Cond: (st.establishment_id = r.establishment_id)
16. 0.006 0.049 ↓ 0.0 0 1

Sort (cost=14.94..14.94 rows=1 width=516) (actual time=0.049..0.049 rows=0 loops=1)

  • Sort Key: st.establishment_id
  • Sort Method: quicksort Memory: 25kB
17. 0.043 0.043 ↓ 0.0 0 1

Seq Scan on statistic_tests st (cost=0.00..14.93 rows=1 width=516) (actual time=0.043..0.043 rows=0 loops=1)

  • Filter: (active AND (NOT archived) AND ((type)::text = 'age'::text))
  • Rows Removed by Filter: 154
18. 0.000 0.000 ↓ 0.0 0

Materialize (cost=19.01..21.81 rows=80 width=57) (never executed)

19. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=19.01..20.81 rows=80 width=57) (never executed)

  • Group Key: r.establishment_id, e.name
20. 0.000 0.000 ↓ 0.0 0

Sort (cost=19.01..19.21 rows=80 width=36) (never executed)

  • Sort Key: r.establishment_id, e.name
21. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=11.87..16.49 rows=80 width=36) (never executed)

  • Hash Cond: (r.establishment_id = e.id)
22. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=6.97..11.35 rows=80 width=15) (never executed)

  • Hash Cond: (ru.user_id = u.id)
23. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=2.10..6.26 rows=80 width=8) (never executed)

  • Hash Cond: (ru.role_id = r.id)
24. 0.000 0.000 ↓ 0.0 0

Seq Scan on role_users ru (cost=0.00..3.93 rows=80 width=8) (never executed)

  • Filter: alerts_flag
25. 0.000 0.000 ↓ 0.0 0

Hash (cost=1.49..1.49 rows=49 width=8) (never executed)

26. 0.000 0.000 ↓ 0.0 0

Seq Scan on roles r (cost=0.00..1.49 rows=49 width=8) (never executed)

27. 0.000 0.000 ↓ 0.0 0

Hash (cost=3.83..3.83 rows=83 width=15) (never executed)

28. 0.000 0.000 ↓ 0.0 0

Seq Scan on users u (cost=0.00..3.83 rows=83 width=15) (never executed)

29. 0.000 0.000 ↓ 0.0 0

Hash (cost=4.40..4.40 rows=40 width=25) (never executed)

30. 0.000 0.000 ↓ 0.0 0

Seq Scan on establishments e (cost=0.00..4.40 rows=40 width=25) (never executed)

31. 0.000 0.000 ↓ 0.0 0

Index Scan using heartbeats_sensor_receivedat on heartbeats h (cost=0.43..298.21 rows=6,783 width=16) (never executed)

  • Index Cond: (sensor_id = s.id)
32. 0.000 0.000 ↓ 0.0 0

Hash (cost=14.71..14.71 rows=771 width=24) (never executed)

33. 0.000 0.000 ↓ 0.0 0

Seq Scan on line_sensors ls (cost=0.00..14.71 rows=771 width=24) (never executed)

34. 0.000 0.000 ↓ 0.0 0

Hash (cost=12.02..12.02 rows=602 width=11) (never executed)

35. 0.000 0.000 ↓ 0.0 0

Seq Scan on lines l (cost=0.00..12.02 rows=602 width=11) (never executed)

Planning time : 8.412 ms
Execution time : 1.133 ms