explain.depesz.com

PostgreSQL's explain analyze made readable

Result: L8MKw

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

Unique (cost=78,057.25..78,489.75 rows=57,667 width=1,112) (actual time=4.505..4.505 rows=0 loops=1)

2. 0.021 4.505 ↓ 0.0 0 1

Sort (cost=78,057.25..78,201.41 rows=57,667 width=1,112) (actual time=4.505..4.505 rows=0 loops=1)

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

Hash Left Join (cost=102.78..17,518.10 rows=57,667 width=1,112) (actual time=4.484..4.484 rows=0 loops=1)

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

Hash Left Join (cost=83.24..16,769.44 rows=57,667 width=1,093) (actual time=4.484..4.484 rows=0 loops=1)

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

Nested Loop Left Join (cost=58.89..15,891.97 rows=57,667 width=1,089) (actual time=4.483..4.483 rows=0 loops=1)

  • Join Filter: s.enumerated
6. 0.014 4.483 ↓ 0.0 0 1

Hash Join (cost=58.46..152.38 rows=43 width=1,073) (actual time=4.483..4.483 rows=0 loops=1)

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

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

8. 0.000 4.463 ↓ 0.0 0 1

Hash (cost=58.32..58.32 rows=11 width=1,072) (actual time=4.463..4.463 rows=0 loops=1)

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

Hash Join (cost=49.08..58.32 rows=11 width=1,072) (actual time=4.463..4.463 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..8.00 rows=300 width=8) (actual time=0.003..0.003 rows=1 loops=1)

11. 0.000 4.448 ↓ 0.0 0 1

Hash (cost=49.04..49.04 rows=3 width=1,072) (actual time=4.448..4.448 rows=0 loops=1)

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

Hash Join (cost=36.98..49.04 rows=3 width=1,072) (actual time=4.447..4.448 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.001 4.434 ↓ 0.0 0 1

Hash (cost=36.97..36.97 rows=1 width=1,064) (actual time=4.434..4.434 rows=0 loops=1)

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

Merge Left Join (cost=33.95..36.97 rows=1 width=1,064) (actual time=4.433..4.433 rows=0 loops=1)

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

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

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

Seq Scan on statistic_tests st (cost=0.00..14.93 rows=1 width=516) (actual time=4.423..4.423 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=552) (never executed)

19. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=19.01..20.81 rows=80 width=552) (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=531) (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=531) (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=520) (never executed)

30. 0.000 0.000 ↓ 0.0 0

Seq Scan on establishments e (cost=0.00..4.40 rows=40 width=520) (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 : 4.978 ms
Execution time : 4.877 ms