explain.depesz.com

PostgreSQL's explain analyze made readable

Result: LV9x

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.084 3,352.473 ↓ 2.0 24 1

Hash Left Join (cost=11,309,144.60..11,704,776.31 rows=12 width=317) (actual time=2,891.873..3,352.473 rows=24 loops=1)

  • Hash Cond: (l.establishment_id = e.id)
2. 0.213 3,352.315 ↓ 2.0 24 1

Merge Left Join (cost=11,309,137.11..11,704,768.66 rows=12 width=294) (actual time=2,891.782..3,352.315 rows=24 loops=1)

  • Merge Cond: (ls_1.sensor_id = h.sensor_id)
3. 0.064 1,752.549 ↓ 2.0 24 1

Sort (cost=11,309,136.68..11,309,136.71 rows=12 width=274) (actual time=1,752.532..1,752.549 rows=24 loops=1)

  • Sort Key: ls_1.sensor_id
  • Sort Method: quicksort Memory: 30kB
4. 0.026 1,752.485 ↓ 2.0 24 1

Merge Left Join (cost=11,297,545.62..11,309,136.46 rows=12 width=274) (actual time=1,696.244..1,752.485 rows=24 loops=1)

  • Merge Cond: (l.id = ls_1.line_id)
5. 0.023 1,012.936 ↓ 2.0 24 1

Merge Left Join (cost=5,671,371.56..5,681,311.84 rows=12 width=254) (actual time=974.433..1,012.936 rows=24 loops=1)

  • Merge Cond: (l.id = le.line_id)
6. 0.033 1,008.443 ↓ 2.0 24 1

Merge Left Join (cost=5,629,593.91..5,639,476.85 rows=12 width=230) (actual time=970.057..1,008.443 rows=24 loops=1)

  • Merge Cond: (l.id = ls.line_id)
7. 0.024 0.814 ↓ 2.0 24 1

Sort (cost=45.86..45.89 rows=12 width=162) (actual time=0.808..0.814 rows=24 loops=1)

  • Sort Key: l.id
  • Sort Method: quicksort Memory: 26kB
8. 0.127 0.790 ↓ 2.0 24 1

Seq Scan on lines l (cost=0.00..45.64 rows=12 width=162) (actual time=0.706..0.790 rows=24 loops=1)

  • Filter: ((NOT archived) AND (establishment_id = 65) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 1 or hashed SubPlan 2)))
  • Rows Removed by Filter: 648
9.          

SubPlan (for Seq Scan)

10. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (l.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
11. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
12. 0.663 0.663 ↑ 1.0 1 1

Function Scan on unnest _p_1 (cost=0.01..0.03 rows=1 width=4) (actual time=0.662..0.663 rows=1 loops=1)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
13. 34.653 1,007.596 ↑ 20.1 19 1

GroupAggregate (cost=5,629,548.06..5,639,426.10 rows=381 width=72) (actual time=969.242..1,007.596 rows=19 loops=1)

  • Group Key: ls.line_id
14. 97.841 972.943 ↑ 2.9 111,666 1

Sort (cost=5,629,548.06..5,630,370.91 rows=329,141 width=44) (actual time=959.071..972.943 rows=111,666 loops=1)

  • Sort Key: ls.line_id
  • Sort Method: external merge Disk: 6,336kB
15. 67.765 875.102 ↑ 2.9 111,666 1

Hash Left Join (cost=57,998.60..5,589,259.51 rows=329,141 width=44) (actual time=11.138..875.102 rows=111,666 loops=1)

  • Hash Cond: (p.sensor_id = ls.sensor_id)
  • Join Filter: (ls.connected @> p.poured_at)
  • Rows Removed by Join Filter: 1,540
16. 796.288 796.404 ↑ 2.9 111,666 1

Seq Scan on pours p (cost=0.00..5,527,112.89 rows=329,141 width=44) (actual time=0.136..796.404 rows=111,666 loops=1)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 7 or hashed SubPlan 10))
  • Rows Removed by Filter: 529,423
17.          

SubPlan (for Seq Scan)

18. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

19. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = p.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 5 or hashed SubPlan 6)))
20.          

SubPlan (for Index Scan)

21. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
22. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_4 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
23. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_5 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
24. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_6 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('pours#select'::text ~* (('^'::text || permission) || '$'::text))
25. 0.001 0.116 ↑ 1.0 1 1

Nested Loop (cost=0.01..19.17 rows=1 width=4) (actual time=0.093..0.116 rows=1 loops=1)

26. 0.086 0.105 ↑ 1.0 1 1

Seq Scan on gateways g_1 (cost=0.00..19.13 rows=1 width=4) (actual time=0.082..0.105 rows=1 loops=1)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 8 or hashed SubPlan 9)))
  • Rows Removed by Filter: 74
27.          

SubPlan (for Seq Scan)

28. 0.002 0.019 ↑ 1.0 1 1

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.019..0.019 rows=1 loops=1)

  • One-Time Filter: (g_1.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
29. 0.017 0.017 ↑ 1.0 1 1

Function Scan on unnest _p_7 (cost=0.02..0.04 rows=1 width=0) (actual time=0.017..0.017 rows=1 loops=1)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
30. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_8 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
31. 0.010 0.010 ↑ 1.0 1 1

Function Scan on unnest _p_9 (cost=0.01..0.03 rows=1 width=0) (actual time=0.010..0.010 rows=1 loops=1)

  • Filter: ('pours#select'::text ~* (('^'::text || permission) || '$'::text))
32. 0.026 10.933 ↑ 10.8 40 1

Hash (cost=57,993.20..57,993.20 rows=432 width=24) (actual time=10.932..10.933 rows=40 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
33. 0.179 10.907 ↑ 10.8 40 1

Seq Scan on line_sensors ls (cost=0.00..57,993.20 rows=432 width=24) (actual time=1.336..10.907 rows=40 loops=1)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 39 or hashed SubPlan 68))
  • Rows Removed by Filter: 854
34.          

SubPlan (for Seq Scan)

35. 0.854 10.728 ↓ 0.0 0 894

Nested Loop (cost=0.98..67.40 rows=1 width=0) (actual time=0.012..0.012 rows=0 loops=894)

36. 0.000 9.834 ↓ 0.0 0 894

Nested Loop (cost=0.97..67.37 rows=1 width=0) (actual time=0.011..0.011 rows=0 loops=894)

37. 0.000 9.834 ↓ 0.0 0 894

Nested Loop (cost=0.69..59.01 rows=1 width=0) (actual time=0.011..0.011 rows=0 loops=894)

38. 0.694 9.834 ↓ 0.0 0 894

Nested Loop (cost=0.55..57.93 rows=1 width=4) (actual time=0.011..0.011 rows=0 loops=894)

39. 3.576 8.940 ↓ 0.0 0 894

Index Scan using sensors_pkey on sensors s (cost=0.28..41.18 rows=1 width=4) (actual time=0.010..0.010 rows=0 loops=894)

  • Index Cond: (id = ls.sensor_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 21 or hashed SubPlan 30))
  • Rows Removed by Filter: 1
40.          

SubPlan (for Index Scan)

41. 0.000 5.364 ↓ 0.0 0 894

Nested Loop (cost=0.42..32.87 rows=1 width=0) (actual time=0.006..0.006 rows=0 loops=894)

42. 0.774 5.364 ↓ 0.0 0 894

Nested Loop (cost=0.42..32.84 rows=1 width=0) (actual time=0.006..0.006 rows=0 loops=894)

43. 0.894 4.470 ↓ 0.0 0 894

Index Scan using brus_pkey on brus b (cost=0.27..16.55 rows=1 width=4) (actual time=0.005..0.005 rows=0 loops=894)

  • Index Cond: (id = s.bru_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 15 or hashed SubPlan 18))
  • Rows Removed by Filter: 1
44.          

SubPlan (for Index Scan)

45. 2.642 3.576 ↓ 0.0 0 894

Nested Loop (cost=0.15..8.25 rows=1 width=0) (actual time=0.004..0.004 rows=0 loops=894)

46. 0.814 0.894 ↓ 0.0 0 894

Index Scan using gateways_pkey on gateways g_2 (cost=0.14..8.21 rows=1 width=0) (actual time=0.001..0.001 rows=0 loops=894)

  • Index Cond: (id = b.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 13 or hashed SubPlan 14)))
  • Rows Removed by Filter: 1
47.          

SubPlan (for Index Scan)

48. 0.040 0.080 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=40)

  • One-Time Filter: (g_2.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
49. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_12 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
50. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_13 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
51. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_14 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
52. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

53. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_3 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 16 or hashed SubPlan 17)))
54.          

SubPlan (for Seq Scan)

55. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_3.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
56. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_15 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
57. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_16 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
58. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_17 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
59. 0.080 0.120 ↑ 1.0 1 40

Index Scan using gateways_pkey on gateways g_4 (cost=0.14..8.21 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=40)

  • Index Cond: (id = b.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 19 or hashed SubPlan 20)))
60.          

SubPlan (for Index Scan)

61. 0.000 0.040 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • One-Time Filter: (g_4.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
62. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_18 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
63. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_19 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
64. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_20 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
65. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..2,721.85 rows=2 width=4) (never executed)

  • Join Filter: (g_7.id = b_1.gateway_id)
66. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

67. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_29 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
68. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_7 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 28 or hashed SubPlan 29)))
69.          

SubPlan (for Seq Scan)

70. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_7.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
71. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_27 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
72. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_28 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
73. 0.000 0.000 ↓ 0.0 0

Seq Scan on brus b_1 (cost=0.00..2,700.67 rows=161 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 24 or hashed SubPlan 27))
74.          

SubPlan (for Seq Scan)

75. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

76. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_5 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_1.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 22 or hashed SubPlan 23)))
77.          

SubPlan (for Index Scan)

78. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_5.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
79. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_21 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
80. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_22 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
81. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_23 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
82. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

83. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_6 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 25 or hashed SubPlan 26)))
84.          

SubPlan (for Seq Scan)

85. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_6.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
86. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_24 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
87. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_25 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
88. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_26 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
89. 0.040 0.200 ↑ 1.0 1 40

Index Scan using brus_pkey on brus b_2 (cost=0.27..16.55 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=40)

  • Index Cond: (id = s.bru_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 33 or hashed SubPlan 36))
90.          

SubPlan (for Index Scan)

91. 0.000 0.160 ↑ 1.0 1 40

Nested Loop (cost=0.15..8.25 rows=1 width=0) (actual time=0.004..0.004 rows=1 loops=40)

92. 0.080 0.120 ↑ 1.0 1 40

Index Scan using gateways_pkey on gateways g_8 (cost=0.14..8.21 rows=1 width=0) (actual time=0.003..0.003 rows=1 loops=40)

  • Index Cond: (id = b_2.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 31 or hashed SubPlan 32)))
93.          

SubPlan (for Index Scan)

94. 0.000 0.040 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • One-Time Filter: (g_8.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
95. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_30 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
96. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_31 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
97. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_32 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
98. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

99. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_9 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 34 or hashed SubPlan 35)))
100.          

SubPlan (for Seq Scan)

101. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_9.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
102. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_33 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
103. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_34 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
104. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_35 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
105. 0.120 0.160 ↑ 1.0 1 40

Index Scan using gateways_pkey on gateways g_10 (cost=0.14..0.61 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=40)

  • Index Cond: (id = b_2.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 37 or hashed SubPlan 38)))
106.          

SubPlan (for Index Scan)

107. 0.000 0.040 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • One-Time Filter: (g_10.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
108. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_36 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
109. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_37 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
110. 0.160 0.200 ↑ 1.0 1 40

Index Scan using lines_pkey on lines l_1 (cost=0.28..8.35 rows=1 width=0) (actual time=0.005..0.005 rows=1 loops=40)

  • Index Cond: (id = ls.line_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 11 or hashed SubPlan 12)))
111.          

SubPlan (for Index Scan)

112. 0.000 0.040 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • One-Time Filter: (l_1.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
113. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_10 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
114. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_11 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
115. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_38 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('line_sensors#select'::text ~* (('^'::text || permission) || '$'::text))
116. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..42,894.13 rows=46 width=8) (never executed)

117. 0.000 0.000 ↓ 0.0 0

Seq Scan on lines l_2 (cost=0.00..50.68 rows=12 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 40 or hashed SubPlan 41)))
118.          

SubPlan (for Seq Scan)

119. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (l_2.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
120. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_39 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
121. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_40 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
122. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.01..42,842.86 rows=4 width=4) (never executed)

123. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..42,842.84 rows=4 width=4) (never executed)

  • Join Filter: (b_5.id = s_1.bru_id)
124. 0.000 0.000 ↓ 0.0 0

Seq Scan on sensors s_1 (cost=0.00..40,102.71 rows=609 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 50 or hashed SubPlan 59))
125.          

SubPlan (for Seq Scan)

126. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..32.87 rows=1 width=0) (never executed)

127. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..32.84 rows=1 width=0) (never executed)

128. 0.000 0.000 ↓ 0.0 0

Index Scan using brus_pkey on brus b_3 (cost=0.27..16.55 rows=1 width=4) (never executed)

  • Index Cond: (id = s_1.bru_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 44 or hashed SubPlan 47))
129.          

SubPlan (for Index Scan)

130. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

131. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_11 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_3.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 42 or hashed SubPlan 43)))
132.          

SubPlan (for Index Scan)

133. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_11.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
134. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_41 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
135. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_42 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
136. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_43 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
137. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

138. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_12 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 45 or hashed SubPlan 46)))
139.          

SubPlan (for Seq Scan)

140. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_12.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
141. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_44 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
142. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_45 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
143. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_46 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
144. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_13 (cost=0.14..8.21 rows=1 width=4) (never executed)

  • Index Cond: (id = b_3.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 48 or hashed SubPlan 49)))
145.          

SubPlan (for Index Scan)

146. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_13.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
147. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_47 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
148. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_48 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
149. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_49 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
150. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..2,721.85 rows=2 width=4) (never executed)

  • Join Filter: (g_16.id = b_4.gateway_id)
151. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

152. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_58 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
153. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_16 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 57 or hashed SubPlan 58)))
154.          

SubPlan (for Seq Scan)

155. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_16.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
156. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_56 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
157. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_57 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
158. 0.000 0.000 ↓ 0.0 0

Seq Scan on brus b_4 (cost=0.00..2,700.67 rows=161 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 53 or hashed SubPlan 56))
159.          

SubPlan (for Seq Scan)

160. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

161. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_14 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_4.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 51 or hashed SubPlan 52)))
162.          

SubPlan (for Index Scan)

163. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_14.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
164. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_50 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
165. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_51 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
166. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_52 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
167. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

168. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_15 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 54 or hashed SubPlan 55)))
169.          

SubPlan (for Seq Scan)

170. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_15.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
171. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_53 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
172. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_54 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
173. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_55 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
174. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.01..2,721.86 rows=2 width=4) (never executed)

175. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..2,721.85 rows=2 width=4) (never executed)

  • Join Filter: (g_19.id = b_5.gateway_id)
176. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

177. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_67 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('line_sensors#select'::text ~* (('^'::text || permission) || '$'::text))
178. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_19 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 66 or hashed SubPlan 67)))
179.          

SubPlan (for Seq Scan)

180. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_19.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
181. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_65 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
182. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_66 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
183. 0.000 0.000 ↓ 0.0 0

Seq Scan on brus b_5 (cost=0.00..2,700.67 rows=161 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 62 or hashed SubPlan 65))
184.          

SubPlan (for Seq Scan)

185. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

186. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_17 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_5.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 60 or hashed SubPlan 61)))
187.          

SubPlan (for Index Scan)

188. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_17.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
189. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_59 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
190. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_60 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
191. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_61 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
192. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

193. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_18 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 63 or hashed SubPlan 64)))
194.          

SubPlan (for Seq Scan)

195. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_18.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
196. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_62 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
197. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_63 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
198. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_64 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
199. 0.148 4.470 ↑ 18.6 18 1

GroupAggregate (cost=41,777.64..41,830.72 rows=334 width=28) (actual time=4.370..4.470 rows=18 loops=1)

  • Group Key: le.line_id
200. 0.120 4.322 ↑ 8.0 312 1

Sort (cost=41,777.64..41,783.86 rows=2,487 width=16) (actual time=4.289..4.322 rows=312 loops=1)

  • Sort Key: le.line_id
  • Sort Method: quicksort Memory: 39kB
201. 3.367 4.202 ↑ 8.0 312 1

Seq Scan on line_events le (cost=0.00..41,637.38 rows=2,487 width=16) (actual time=0.991..4.202 rows=312 loops=1)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 71 or hashed SubPlan 74))
  • Rows Removed by Filter: 4,517
202.          

SubPlan (for Seq Scan)

203. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.28..8.38 rows=1 width=0) (never executed)

204. 0.000 0.000 ↓ 0.0 0

Index Scan using lines_pkey on lines l_3 (cost=0.28..8.35 rows=1 width=0) (never executed)

  • Index Cond: (id = le.line_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 69 or hashed SubPlan 70)))
205.          

SubPlan (for Index Scan)

206. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (l_3.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
207. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_68 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
208. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_69 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
209. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_70 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('line_events#select'::text ~* (('^'::text || permission) || '$'::text))
210. 0.005 0.835 ↓ 2.0 24 1

Nested Loop (cost=0.01..50.82 rows=12 width=4) (actual time=0.059..0.835 rows=24 loops=1)

211. 0.026 0.026 ↑ 1.0 1 1

Function Scan on unnest _p_73 (cost=0.01..0.03 rows=1 width=0) (actual time=0.025..0.026 rows=1 loops=1)

  • Filter: ('line_events#select'::text ~* (('^'::text || permission) || '$'::text))
212. 0.795 0.804 ↓ 2.0 24 1

Seq Scan on lines l_4 (cost=0.00..50.68 rows=12 width=4) (actual time=0.033..0.804 rows=24 loops=1)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 72 or hashed SubPlan 73)))
  • Rows Removed by Filter: 648
213.          

SubPlan (for Seq Scan)

214. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (l_4.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
215. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_71 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
216. 0.009 0.009 ↑ 1.0 1 1

Function Scan on unnest _p_72 (cost=0.01..0.03 rows=1 width=4) (actual time=0.008..0.009 rows=1 loops=1)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
217. 6.332 739.523 ↑ 20.1 19 1

Unique (cost=5,626,174.06..5,627,819.76 rows=381 width=24) (actual time=721.803..739.523 rows=19 loops=1)

218. 126.079 733.191 ↑ 3.0 109,975 1

Sort (cost=5,626,174.06..5,626,996.91 rows=329,141 width=24) (actual time=721.801..733.191 rows=109,975 loops=1)

  • Sort Key: ls_1.line_id, p_1.poured_at DESC
  • Sort Method: external merge Disk: 3,720kB
219. 56.837 607.112 ↑ 2.9 111,666 1

Hash Left Join (cost=57,998.60..5,589,259.51 rows=329,141 width=24) (actual time=36.538..607.112 rows=111,666 loops=1)

  • Hash Cond: (p_1.sensor_id = ls_1.sensor_id)
  • Join Filter: (ls_1.connected @> p_1.poured_at)
  • Rows Removed by Join Filter: 1,540
220. 514.089 514.201 ↑ 2.9 111,666 1

Seq Scan on pours p_1 (cost=0.00..5,527,112.89 rows=329,141 width=20) (actual time=0.449..514.201 rows=111,666 loops=1)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 77 or hashed SubPlan 80))
  • Rows Removed by Filter: 529,423
221.          

SubPlan (for Seq Scan)

222. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

223. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_20 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = p_1.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 75 or hashed SubPlan 76)))
224.          

SubPlan (for Index Scan)

225. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_20.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
226. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_74 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
227. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_75 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
228. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_76 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('pours#select'::text ~* (('^'::text || permission) || '$'::text))
229. 0.002 0.112 ↑ 1.0 1 1

Nested Loop (cost=0.01..19.17 rows=1 width=4) (actual time=0.081..0.112 rows=1 loops=1)

230. 0.077 0.103 ↑ 1.0 1 1

Seq Scan on gateways g_21 (cost=0.00..19.13 rows=1 width=4) (actual time=0.073..0.103 rows=1 loops=1)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 78 or hashed SubPlan 79)))
  • Rows Removed by Filter: 74
231.          

SubPlan (for Seq Scan)

232. 0.003 0.026 ↑ 1.0 1 1

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.026..0.026 rows=1 loops=1)

  • One-Time Filter: (g_21.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
233. 0.023 0.023 ↑ 1.0 1 1

Function Scan on unnest _p_77 (cost=0.02..0.04 rows=1 width=0) (actual time=0.023..0.023 rows=1 loops=1)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
234. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_78 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
235. 0.007 0.007 ↑ 1.0 1 1

Function Scan on unnest _p_79 (cost=0.01..0.03 rows=1 width=0) (actual time=0.007..0.007 rows=1 loops=1)

  • Filter: ('pours#select'::text ~* (('^'::text || permission) || '$'::text))
236. 0.025 36.074 ↑ 10.8 40 1

Hash (cost=57,993.20..57,993.20 rows=432 width=24) (actual time=36.074..36.074 rows=40 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
237. 2.077 36.049 ↑ 10.8 40 1

Seq Scan on line_sensors ls_1 (cost=0.00..57,993.20 rows=432 width=24) (actual time=1.024..36.049 rows=40 loops=1)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 109 or hashed SubPlan 138))
  • Rows Removed by Filter: 854
238.          

SubPlan (for Seq Scan)

239. 0.000 33.972 ↓ 0.0 0 894

Nested Loop (cost=0.98..67.40 rows=1 width=0) (actual time=0.038..0.038 rows=0 loops=894)

240. 0.574 33.972 ↓ 0.0 0 894

Nested Loop (cost=0.97..67.37 rows=1 width=0) (actual time=0.038..0.038 rows=0 loops=894)

241. 0.000 33.078 ↓ 0.0 0 894

Nested Loop (cost=0.69..59.01 rows=1 width=0) (actual time=0.037..0.037 rows=0 loops=894)

242. 0.856 33.078 ↓ 0.0 0 894

Nested Loop (cost=0.55..57.93 rows=1 width=4) (actual time=0.037..0.037 rows=0 loops=894)

243. 7.152 29.502 ↓ 0.0 0 894

Index Scan using sensors_pkey on sensors s_2 (cost=0.28..41.18 rows=1 width=4) (actual time=0.033..0.033 rows=0 loops=894)

  • Index Cond: (id = ls_1.sensor_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 91 or hashed SubPlan 100))
  • Rows Removed by Filter: 1
244.          

SubPlan (for Index Scan)

245. 0.000 22.350 ↓ 0.0 0 894

Nested Loop (cost=0.42..32.87 rows=1 width=0) (actual time=0.025..0.025 rows=0 loops=894)

246. 0.694 22.350 ↓ 0.0 0 894

Nested Loop (cost=0.42..32.84 rows=1 width=0) (actual time=0.025..0.025 rows=0 loops=894)

247. 13.410 21.456 ↓ 0.0 0 894

Index Scan using brus_pkey on brus b_6 (cost=0.27..16.55 rows=1 width=4) (actual time=0.024..0.024 rows=0 loops=894)

  • Index Cond: (id = s_2.bru_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 85 or hashed SubPlan 88))
  • Rows Removed by Filter: 1
248.          

SubPlan (for Index Scan)

249. 5.244 8.046 ↓ 0.0 0 894

Nested Loop (cost=0.15..8.25 rows=1 width=0) (actual time=0.009..0.009 rows=0 loops=894)

250. 2.602 2.682 ↓ 0.0 0 894

Index Scan using gateways_pkey on gateways g_22 (cost=0.14..8.21 rows=1 width=0) (actual time=0.003..0.003 rows=0 loops=894)

  • Index Cond: (id = b_6.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 83 or hashed SubPlan 84)))
  • Rows Removed by Filter: 1
251.          

SubPlan (for Index Scan)

252. 0.000 0.080 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=40)

  • One-Time Filter: (g_22.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
253. 0.080 0.080 ↑ 1.0 1 40

Function Scan on unnest _p_82 (cost=0.02..0.04 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
254. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_83 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
255. 0.120 0.120 ↑ 1.0 1 40

Function Scan on unnest _p_84 (cost=0.01..0.03 rows=1 width=0) (actual time=0.003..0.003 rows=1 loops=40)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
256. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

257. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_23 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 86 or hashed SubPlan 87)))
258.          

SubPlan (for Seq Scan)

259. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_23.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
260. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_85 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
261. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_86 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
262. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_87 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
263. 0.120 0.200 ↑ 1.0 1 40

Index Scan using gateways_pkey on gateways g_24 (cost=0.14..8.21 rows=1 width=4) (actual time=0.005..0.005 rows=1 loops=40)

  • Index Cond: (id = b_6.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 89 or hashed SubPlan 90)))
264.          

SubPlan (for Index Scan)

265. 0.040 0.080 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=40)

  • One-Time Filter: (g_24.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
266. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_88 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
267. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_89 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
268. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_90 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
269. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..2,721.85 rows=2 width=4) (never executed)

  • Join Filter: (g_27.id = b_7.gateway_id)
270. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

271. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_99 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
272. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_27 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 98 or hashed SubPlan 99)))
273.          

SubPlan (for Seq Scan)

274. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_27.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
275. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_97 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
276. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_98 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
277. 0.000 0.000 ↓ 0.0 0

Seq Scan on brus b_7 (cost=0.00..2,700.67 rows=161 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 94 or hashed SubPlan 97))
278.          

SubPlan (for Seq Scan)

279. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

280. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_25 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_7.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 92 or hashed SubPlan 93)))
281.          

SubPlan (for Index Scan)

282. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_25.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
283. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_91 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
284. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_92 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
285. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_93 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
286. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

287. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_26 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 95 or hashed SubPlan 96)))
288.          

SubPlan (for Seq Scan)

289. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_26.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
290. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_94 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
291. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_95 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
292. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_96 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
293. 0.280 2.720 ↑ 1.0 1 40

Index Scan using brus_pkey on brus b_8 (cost=0.27..16.55 rows=1 width=8) (actual time=0.068..0.068 rows=1 loops=40)

  • Index Cond: (id = s_2.bru_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 103 or hashed SubPlan 106))
294.          

SubPlan (for Index Scan)

295. 0.040 2.440 ↑ 1.0 1 40

Nested Loop (cost=0.15..8.25 rows=1 width=0) (actual time=0.061..0.061 rows=1 loops=40)

296. 0.120 2.360 ↑ 1.0 1 40

Index Scan using gateways_pkey on gateways g_28 (cost=0.14..8.21 rows=1 width=0) (actual time=0.059..0.059 rows=1 loops=40)

  • Index Cond: (id = b_8.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 101 or hashed SubPlan 102)))
297.          

SubPlan (for Index Scan)

298. 2.200 2.240 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.056..0.056 rows=1 loops=40)

  • One-Time Filter: (g_28.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
299. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_100 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
300. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_101 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
301. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_102 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
302. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

303. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_29 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 104 or hashed SubPlan 105)))
304.          

SubPlan (for Seq Scan)

305. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_29.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
306. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_103 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
307. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_104 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
308. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_105 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
309. 0.120 0.200 ↑ 1.0 1 40

Index Scan using gateways_pkey on gateways g_30 (cost=0.14..0.61 rows=1 width=4) (actual time=0.005..0.005 rows=1 loops=40)

  • Index Cond: (id = b_8.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 107 or hashed SubPlan 108)))
310.          

SubPlan (for Index Scan)

311. 0.040 0.080 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=40)

  • One-Time Filter: (g_30.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
312. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_106 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
313. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_107 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
314. 0.240 0.320 ↑ 1.0 1 40

Index Scan using lines_pkey on lines l_5 (cost=0.28..8.35 rows=1 width=0) (actual time=0.008..0.008 rows=1 loops=40)

  • Index Cond: (id = ls_1.line_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 81 or hashed SubPlan 82)))
315.          

SubPlan (for Index Scan)

316. 0.040 0.080 ↑ 1.0 1 40

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=40)

  • One-Time Filter: (l_5.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
317. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_80 (cost=0.02..0.04 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
318. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_81 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
319. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_108 (cost=0.01..0.03 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=40)

  • Filter: ('line_sensors#select'::text ~* (('^'::text || permission) || '$'::text))
320. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..42,894.13 rows=46 width=8) (never executed)

321. 0.000 0.000 ↓ 0.0 0

Seq Scan on lines l_6 (cost=0.00..50.68 rows=12 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 110 or hashed SubPlan 111)))
322.          

SubPlan (for Seq Scan)

323. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (l_6.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
324. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_109 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
325. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_110 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
326. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.01..42,842.86 rows=4 width=4) (never executed)

327. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..42,842.84 rows=4 width=4) (never executed)

  • Join Filter: (b_11.id = s_3.bru_id)
328. 0.000 0.000 ↓ 0.0 0

Seq Scan on sensors s_3 (cost=0.00..40,102.71 rows=609 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 120 or hashed SubPlan 129))
329.          

SubPlan (for Seq Scan)

330. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..32.87 rows=1 width=0) (never executed)

331. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.42..32.84 rows=1 width=0) (never executed)

332. 0.000 0.000 ↓ 0.0 0

Index Scan using brus_pkey on brus b_9 (cost=0.27..16.55 rows=1 width=4) (never executed)

  • Index Cond: (id = s_3.bru_id)
  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 114 or hashed SubPlan 117))
333.          

SubPlan (for Index Scan)

334. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

335. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_31 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_9.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 112 or hashed SubPlan 113)))
336.          

SubPlan (for Index Scan)

337. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_31.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
338. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_111 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
339. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_112 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
340. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_113 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
341. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

342. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_32 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 115 or hashed SubPlan 116)))
343.          

SubPlan (for Seq Scan)

344. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_32.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
345. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_114 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
346. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_115 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
347. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_116 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
348. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_33 (cost=0.14..8.21 rows=1 width=4) (never executed)

  • Index Cond: (id = b_9.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 118 or hashed SubPlan 119)))
349.          

SubPlan (for Index Scan)

350. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_33.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
351. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_117 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
352. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_118 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
353. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_119 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
354. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..2,721.85 rows=2 width=4) (never executed)

  • Join Filter: (g_36.id = b_10.gateway_id)
355. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

356. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_128 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
357. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_36 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 127 or hashed SubPlan 128)))
358.          

SubPlan (for Seq Scan)

359. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_36.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
360. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_126 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
361. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_127 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
362. 0.000 0.000 ↓ 0.0 0

Seq Scan on brus b_10 (cost=0.00..2,700.67 rows=161 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 123 or hashed SubPlan 126))
363.          

SubPlan (for Seq Scan)

364. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

365. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_34 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_10.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 121 or hashed SubPlan 122)))
366.          

SubPlan (for Index Scan)

367. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_34.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
368. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_120 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
369. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_121 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
370. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_122 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
371. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

372. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_35 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 124 or hashed SubPlan 125)))
373.          

SubPlan (for Seq Scan)

374. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_35.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
375. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_123 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
376. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_124 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
377. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_125 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
378. 0.000 0.000 ↓ 0.0 0

Materialize (cost=0.01..2,721.86 rows=2 width=4) (never executed)

379. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..2,721.85 rows=2 width=4) (never executed)

  • Join Filter: (g_39.id = b_11.gateway_id)
380. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

381. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_137 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('line_sensors#select'::text ~* (('^'::text || permission) || '$'::text))
382. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_39 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 136 or hashed SubPlan 137)))
383.          

SubPlan (for Seq Scan)

384. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_39.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
385. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_135 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
386. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_136 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
387. 0.000 0.000 ↓ 0.0 0

Seq Scan on brus b_11 (cost=0.00..2,700.67 rows=161 width=8) (never executed)

  • Filter: (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 132 or hashed SubPlan 135))
388.          

SubPlan (for Seq Scan)

389. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.15..8.25 rows=1 width=0) (never executed)

390. 0.000 0.000 ↓ 0.0 0

Index Scan using gateways_pkey on gateways g_37 (cost=0.14..8.21 rows=1 width=0) (never executed)

  • Index Cond: (id = b_11.gateway_id)
  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 130 or hashed SubPlan 131)))
391.          

SubPlan (for Index Scan)

392. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_37.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
393. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_129 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
394. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_130 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
395. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_131 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
396. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.01..19.17 rows=1 width=4) (never executed)

397. 0.000 0.000 ↓ 0.0 0

Seq Scan on gateways g_38 (cost=0.00..19.13 rows=1 width=4) (never executed)

  • Filter: ((establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 133 or hashed SubPlan 134)))
398.          

SubPlan (for Seq Scan)

399. 0.000 0.000 ↓ 0.0 0

Result (cost=0.02..0.04 rows=1 width=0) (never executed)

  • One-Time Filter: (g_38.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
400. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_132 (cost=0.02..0.04 rows=1 width=0) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
401. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_133 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
402. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_134 (cost=0.01..0.03 rows=1 width=0) (never executed)

  • Filter: ('brus#select'::text ~* (('^'::text || permission) || '$'::text))
403. 97.815 1,599.553 ↑ 6.7 76 1

Unique (cost=0.43..395,625.44 rows=509 width=36) (actual time=0.029..1,599.553 rows=76 loops=1)

404. 1,501.738 1,501.738 ↑ 2.6 1,596,226 1

Index Scan using heartbeats_sensor_receivedat on heartbeats h (cost=0.43..385,065.94 rows=4,223,800 width=36) (actual time=0.028..1,501.738 rows=1,596,226 loops=1)

405. 0.003 0.074 ↑ 1.0 1 1

Hash (cost=7.47..7.47 rows=1 width=27) (actual time=0.074..0.074 rows=1 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
406. 0.036 0.071 ↑ 1.0 1 1

Seq Scan on establishments e (cost=0.00..7.47 rows=1 width=27) (actual time=0.064..0.071 rows=1 loops=1)

  • Filter: ((id = 65) AND (((current_setting('bartrack.currentroleuser'::text))::integer = 0) OR (alternatives: SubPlan 3 or hashed SubPlan 4)))
  • Rows Removed by Filter: 44
407.          

SubPlan (for Seq Scan)

408. 0.003 0.035 ↑ 1.0 1 1

Result (cost=0.02..0.04 rows=1 width=0) (actual time=0.035..0.035 rows=1 loops=1)

  • One-Time Filter: (e.id = (current_setting('bartrack.currentestablishment'::text))::integer)
409. 0.032 0.032 ↑ 1.0 1 1

Function Scan on unnest _p_2 (cost=0.02..0.04 rows=1 width=0) (actual time=0.032..0.032 rows=1 loops=1)

  • Filter: ('establishments#select'::text ~* (('^'::text || permission) || '$'::text))
410. 0.000 0.000 ↓ 0.0 0

Function Scan on unnest _p_3 (cost=0.01..0.03 rows=1 width=4) (never executed)

  • Filter: ('establishments#select'::text ~* (('^'::text || permission) || '$'::text))
Planning time : 16.802 ms
Execution time : 3,360.237 ms