explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2flP : Optimization for: plan #LV9x

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.040 1,603.088 ↓ 2.0 24 1

Hash Left Join (cost=11,301,807.19..11,313,402.61 rows=12 width=294) (actual time=1,541.441..1,603.088 rows=24 loops=1)

  • Hash Cond: (l.establishment_id = e.id)
2. 0.029 1,602.979 ↓ 2.0 24 1

Merge Left Join (cost=11,301,799.70..11,313,394.96 rows=12 width=270) (actual time=1,541.356..1,602.979 rows=24 loops=1)

  • Merge Cond: (l.id = ls_1.line_id)
3. 0.021 1,105.842 ↓ 2.0 24 1

Merge Left Join (cost=5,673,498.60..5,683,442.66 rows=12 width=254) (actual time=1,067.494..1,105.842 rows=24 loops=1)

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

Merge Left Join (cost=5,631,720.96..5,641,607.67 rows=12 width=230) (actual time=1,065.564..1,103.792 rows=24 loops=1)

  • Merge Cond: (l.id = ls.line_id)
5. 0.026 0.149 ↓ 2.0 24 1

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

  • Sort Key: l.id
  • Sort Method: quicksort Memory: 26kB
6. 0.101 0.123 ↓ 2.0 24 1

Seq Scan on lines l (cost=0.00..45.64 rows=12 width=162) (actual time=0.047..0.123 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
7.          

SubPlan (for Seq Scan)

8. 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)
9. 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))
10. 0.022 0.022 ↑ 1.0 1 1

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

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
11. 29.153 1,103.610 ↑ 20.1 19 1

GroupAggregate (cost=5,631,675.10..5,641,556.92 rows=381 width=72) (actual time=1,065.416..1,103.610 rows=19 loops=1)

  • Group Key: ls.line_id
12. 117.701 1,074.457 ↑ 2.9 111,671 1

Sort (cost=5,631,675.10..5,632,498.27 rows=329,267 width=44) (actual time=1,062.327..1,074.457 rows=111,671 loops=1)

  • Sort Key: ls.line_id
  • Sort Method: external merge Disk: 6,336kB
13. 72.240 956.756 ↑ 2.9 111,671 1

Hash Left Join (cost=57,998.60..5,591,370.60 rows=329,267 width=44) (actual time=7.059..956.756 rows=111,671 loops=1)

  • Hash Cond: (p.sensor_id = ls.sensor_id)
  • Join Filter: (ls.connected @> p.poured_at)
  • Rows Removed by Join Filter: 1,540
14. 877.492 877.594 ↑ 2.9 111,671 1

Seq Scan on pours p (cost=0.00..5,529,222.39 rows=329,267 width=44) (actual time=0.120..877.594 rows=111,671 loops=1)

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

SubPlan (for Seq Scan)

16. 0.000 0.000 ↓ 0.0 0

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

17. 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)))
18.          

SubPlan (for Index Scan)

19. 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)
20. 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))
21. 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))
22. 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))
23. 0.002 0.102 ↑ 1.0 1 1

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

24. 0.083 0.095 ↑ 1.0 1 1

Seq Scan on gateways g_1 (cost=0.00..19.13 rows=1 width=4) (actual time=0.075..0.095 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
25.          

SubPlan (for Seq Scan)

26. 0.002 0.012 ↑ 1.0 1 1

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

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

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

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
28. 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))
29. 0.005 0.005 ↑ 1.0 1 1

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

  • Filter: ('pours#select'::text ~* (('^'::text || permission) || '$'::text))
30. 0.016 6.922 ↑ 10.8 40 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
31. 0.648 6.906 ↑ 10.8 40 1

Seq Scan on line_sensors ls (cost=0.00..57,993.20 rows=432 width=24) (actual time=0.522..6.906 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
32.          

SubPlan (for Seq Scan)

33. 0.000 6.258 ↓ 0.0 0 894

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

34. 0.000 6.258 ↓ 0.0 0 894

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

35. 0.774 6.258 ↓ 0.0 0 894

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

36. 0.000 5.364 ↓ 0.0 0 894

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

37. 1.788 5.364 ↓ 0.0 0 894

Index Scan using sensors_pkey on sensors s (cost=0.28..41.18 rows=1 width=4) (actual time=0.006..0.006 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
38.          

SubPlan (for Index Scan)

39. 0.000 3.576 ↓ 0.0 0 894

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

40. 0.774 3.576 ↓ 0.0 0 894

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

41. 0.894 2.682 ↓ 0.0 0 894

Index Scan using brus_pkey on brus b (cost=0.27..16.55 rows=1 width=4) (actual time=0.003..0.003 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
42.          

SubPlan (for Index Scan)

43. 0.854 1.788 ↓ 0.0 0 894

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

44. 0.854 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
45.          

SubPlan (for Index Scan)

46. 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_2.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
47. 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))
48. 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))
49. 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))
50. 0.000 0.000 ↓ 0.0 0

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

51. 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)))
52.          

SubPlan (for Seq Scan)

53. 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)
54. 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))
55. 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))
56. 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))
57. 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)))
58.          

SubPlan (for Index Scan)

59. 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)
60. 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))
61. 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))
62. 0.080 0.080 ↑ 1.0 1 40

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

  • Filter: ('sensors#select'::text ~* (('^'::text || permission) || '$'::text))
63. 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)
64. 0.000 0.000 ↓ 0.0 0

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

65. 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))
66. 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)))
67.          

SubPlan (for Seq Scan)

68. 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)
69. 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))
70. 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))
71. 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))
72.          

SubPlan (for Seq Scan)

73. 0.000 0.000 ↓ 0.0 0

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

74. 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)))
75.          

SubPlan (for Index Scan)

76. 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)
77. 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))
78. 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))
79. 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))
80. 0.000 0.000 ↓ 0.0 0

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

81. 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)))
82.          

SubPlan (for Seq Scan)

83. 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)
84. 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))
85. 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))
86. 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))
87. 0.080 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))
88.          

SubPlan (for Index Scan)

89. 0.000 0.120 ↑ 1.0 1 40

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

90. 0.040 0.080 ↑ 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.002..0.002 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)))
91.          

SubPlan (for Index Scan)

92. 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)
93. 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))
94. 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))
95. 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))
96. 0.000 0.000 ↓ 0.0 0

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

97. 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)))
98.          

SubPlan (for Seq Scan)

99. 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)
100. 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))
101. 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))
102. 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))
103. 0.080 0.120 ↑ 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.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 37 or hashed SubPlan 38)))
104.          

SubPlan (for Index Scan)

105. 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)
106. 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))
107. 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))
108. 0.080 0.160 ↑ 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.004..0.004 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)))
109.          

SubPlan (for Index Scan)

110. 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_1.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
111. 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))
112. 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))
113. 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))
114. 0.000 0.000 ↓ 0.0 0

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

115. 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)))
116.          

SubPlan (for Seq Scan)

117. 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)
118. 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))
119. 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))
120. 0.000 0.000 ↓ 0.0 0

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

121. 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)
122. 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))
123.          

SubPlan (for Seq Scan)

124. 0.000 0.000 ↓ 0.0 0

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

125. 0.000 0.000 ↓ 0.0 0

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

126. 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))
127.          

SubPlan (for Index Scan)

128. 0.000 0.000 ↓ 0.0 0

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

129. 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)))
130.          

SubPlan (for Index Scan)

131. 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)
132. 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))
133. 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))
134. 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))
135. 0.000 0.000 ↓ 0.0 0

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

136. 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)))
137.          

SubPlan (for Seq Scan)

138. 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)
139. 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))
140. 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))
141. 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))
142. 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)))
143.          

SubPlan (for Index Scan)

144. 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)
145. 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))
146. 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))
147. 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))
148. 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)
149. 0.000 0.000 ↓ 0.0 0

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

150. 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))
151. 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)))
152.          

SubPlan (for Seq Scan)

153. 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)
154. 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))
155. 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))
156. 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))
157.          

SubPlan (for Seq Scan)

158. 0.000 0.000 ↓ 0.0 0

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

159. 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)))
160.          

SubPlan (for Index Scan)

161. 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)
162. 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))
163. 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))
164. 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))
165. 0.000 0.000 ↓ 0.0 0

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

166. 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)))
167.          

SubPlan (for Seq Scan)

168. 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)
169. 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))
170. 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))
171. 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))
172. 0.000 0.000 ↓ 0.0 0

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

173. 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)
174. 0.000 0.000 ↓ 0.0 0

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

175. 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))
176. 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)))
177.          

SubPlan (for Seq Scan)

178. 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)
179. 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))
180. 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))
181. 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))
182.          

SubPlan (for Seq Scan)

183. 0.000 0.000 ↓ 0.0 0

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

184. 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)))
185.          

SubPlan (for Index Scan)

186. 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)
187. 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))
188. 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))
189. 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))
190. 0.000 0.000 ↓ 0.0 0

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

191. 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)))
192.          

SubPlan (for Seq Scan)

193. 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)
194. 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))
195. 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))
196. 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))
197. 0.080 2.029 ↑ 18.6 18 1

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

  • Group Key: le.line_id
198. 0.087 1.949 ↑ 8.0 312 1

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

  • Sort Key: le.line_id
  • Sort Method: quicksort Memory: 39kB
199. 1.588 1.862 ↑ 8.0 312 1

Seq Scan on line_events le (cost=0.00..41,637.38 rows=2,487 width=16) (actual time=0.379..1.862 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
200.          

SubPlan (for Seq Scan)

201. 0.000 0.000 ↓ 0.0 0

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

202. 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)))
203.          

SubPlan (for Index Scan)

204. 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)
205. 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))
206. 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))
207. 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))
208. 0.005 0.274 ↓ 2.0 24 1

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

209. 0.022 0.022 ↑ 1.0 1 1

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

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

Seq Scan on lines l_4 (cost=0.00..50.68 rows=12 width=4) (actual time=0.025..0.247 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
211.          

SubPlan (for Seq Scan)

212. 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)
213. 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))
214. 0.007 0.007 ↑ 1.0 1 1

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

  • Filter: ('lines#select'::text ~* (('^'::text || permission) || '$'::text))
215. 6.393 497.108 ↑ 20.1 19 1

Unique (cost=5,628,301.10..5,629,947.44 rows=381 width=24) (actual time=473.854..497.108 rows=19 loops=1)

216. 118.918 490.715 ↑ 3.0 109,980 1

Sort (cost=5,628,301.10..5,629,124.27 rows=329,267 width=24) (actual time=473.852..490.715 rows=109,980 loops=1)

  • Sort Key: ls_1.line_id, p_1.poured_at DESC
  • Sort Method: external merge Disk: 3,712kB
217. 30.201 371.797 ↑ 2.9 111,671 1

Hash Left Join (cost=57,998.60..5,591,370.60 rows=329,267 width=24) (actual time=6.032..371.797 rows=111,671 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
218. 335.603 335.672 ↑ 2.9 111,671 1

Seq Scan on pours p_1 (cost=0.00..5,529,222.39 rows=329,267 width=20) (actual time=0.094..335.672 rows=111,671 loops=1)

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

SubPlan (for Seq Scan)

220. 0.000 0.000 ↓ 0.0 0

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

221. 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)))
222.          

SubPlan (for Index Scan)

223. 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)
224. 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))
225. 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))
226. 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))
227. 0.001 0.069 ↑ 1.0 1 1

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

228. 0.051 0.063 ↑ 1.0 1 1

Seq Scan on gateways g_21 (cost=0.00..19.13 rows=1 width=4) (actual time=0.044..0.063 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
229.          

SubPlan (for Seq Scan)

230. 0.002 0.012 ↑ 1.0 1 1

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

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

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

  • Filter: ('gateways#select'::text ~* (('^'::text || permission) || '$'::text))
232. 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))
233. 0.005 0.005 ↑ 1.0 1 1

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

  • Filter: ('pours#select'::text ~* (('^'::text || permission) || '$'::text))
234. 0.010 5.924 ↑ 10.8 40 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
235. 0.550 5.914 ↑ 10.8 40 1

Seq Scan on line_sensors ls_1 (cost=0.00..57,993.20 rows=432 width=24) (actual time=0.425..5.914 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
236.          

SubPlan (for Seq Scan)

237. 0.000 5.364 ↓ 0.0 0 894

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

238. 0.000 5.364 ↓ 0.0 0 894

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

239. 0.814 5.364 ↓ 0.0 0 894

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

240. 0.000 4.470 ↓ 0.0 0 894

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

241. 1.788 4.470 ↓ 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.005..0.005 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
242.          

SubPlan (for Index Scan)

243. 0.000 2.682 ↓ 0.0 0 894

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

244. 0.000 2.682 ↓ 0.0 0 894

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

245. 1.788 2.682 ↓ 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.003..0.003 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
246.          

SubPlan (for Index Scan)

247. 0.000 0.894 ↓ 0.0 0 894

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

248. 0.854 0.894 ↓ 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.001..0.001 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
249.          

SubPlan (for Index Scan)

250. 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_22.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
251. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_82 (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))
252. 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))
253. 0.040 0.040 ↑ 1.0 1 40

Function Scan on unnest _p_84 (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))
254. 0.000 0.000 ↓ 0.0 0

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

255. 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)))
256.          

SubPlan (for Seq Scan)

257. 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)
258. 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))
259. 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))
260. 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))
261. 0.040 0.080 ↑ 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.002..0.002 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)))
262.          

SubPlan (for Index Scan)

263. 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_24.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
264. 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))
265. 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))
266. 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))
267. 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)
268. 0.000 0.000 ↓ 0.0 0

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

269. 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))
270. 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)))
271.          

SubPlan (for Seq Scan)

272. 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)
273. 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))
274. 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))
275. 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))
276.          

SubPlan (for Seq Scan)

277. 0.000 0.000 ↓ 0.0 0

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

278. 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)))
279.          

SubPlan (for Index Scan)

280. 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)
281. 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))
282. 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))
283. 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))
284. 0.000 0.000 ↓ 0.0 0

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

285. 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)))
286.          

SubPlan (for Seq Scan)

287. 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)
288. 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))
289. 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))
290. 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))
291. 0.080 0.200 ↑ 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.005..0.005 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))
292.          

SubPlan (for Index Scan)

293. 0.000 0.120 ↑ 1.0 1 40

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

294. 0.040 0.080 ↑ 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.002..0.002 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)))
295.          

SubPlan (for Index Scan)

296. 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_28.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
297. 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))
298. 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))
299. 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))
300. 0.000 0.000 ↓ 0.0 0

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

301. 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)))
302.          

SubPlan (for Seq Scan)

303. 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)
304. 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))
305. 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))
306. 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))
307. 0.040 0.080 ↑ 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.002..0.002 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)))
308.          

SubPlan (for Index Scan)

309. 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_30.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
310. 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))
311. 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))
312. 0.080 0.120 ↑ 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.003..0.003 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)))
313.          

SubPlan (for Index Scan)

314. 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_5.establishment_id = (current_setting('bartrack.currentestablishment'::text))::integer)
315. 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))
316. 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))
317. 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))
318. 0.000 0.000 ↓ 0.0 0

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

319. 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)))
320.          

SubPlan (for Seq Scan)

321. 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)
322. 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))
323. 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))
324. 0.000 0.000 ↓ 0.0 0

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

325. 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)
326. 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))
327.          

SubPlan (for Seq Scan)

328. 0.000 0.000 ↓ 0.0 0

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

329. 0.000 0.000 ↓ 0.0 0

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

330. 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))
331.          

SubPlan (for Index Scan)

332. 0.000 0.000 ↓ 0.0 0

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

333. 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)))
334.          

SubPlan (for Index Scan)

335. 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)
336. 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))
337. 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))
338. 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))
339. 0.000 0.000 ↓ 0.0 0

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

340. 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)))
341.          

SubPlan (for Seq Scan)

342. 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)
343. 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))
344. 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))
345. 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))
346. 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)))
347.          

SubPlan (for Index Scan)

348. 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)
349. 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))
350. 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))
351. 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))
352. 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)
353. 0.000 0.000 ↓ 0.0 0

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

354. 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))
355. 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)))
356.          

SubPlan (for Seq Scan)

357. 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)
358. 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))
359. 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))
360. 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))
361.          

SubPlan (for Seq Scan)

362. 0.000 0.000 ↓ 0.0 0

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

363. 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)))
364.          

SubPlan (for Index Scan)

365. 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)
366. 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))
367. 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))
368. 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))
369. 0.000 0.000 ↓ 0.0 0

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

370. 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)))
371.          

SubPlan (for Seq Scan)

372. 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)
373. 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))
374. 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))
375. 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))
376. 0.000 0.000 ↓ 0.0 0

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

377. 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)
378. 0.000 0.000 ↓ 0.0 0

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

379. 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))
380. 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)))
381.          

SubPlan (for Seq Scan)

382. 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)
383. 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))
384. 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))
385. 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))
386.          

SubPlan (for Seq Scan)

387. 0.000 0.000 ↓ 0.0 0

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

388. 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)))
389.          

SubPlan (for Index Scan)

390. 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)
391. 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))
392. 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))
393. 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))
394. 0.000 0.000 ↓ 0.0 0

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

395. 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)))
396.          

SubPlan (for Seq Scan)

397. 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)
398. 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))
399. 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))
400. 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))
401. 0.003 0.069 ↑ 1.0 1 1

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

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
402. 0.039 0.066 ↑ 1.0 1 1

Seq Scan on establishments e (cost=0.00..7.47 rows=1 width=27) (actual time=0.058..0.066 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
403.          

SubPlan (for Seq Scan)

404. 0.003 0.027 ↑ 1.0 1 1

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

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

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

  • Filter: ('establishments#select'::text ~* (('^'::text || permission) || '$'::text))
406. 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 : 9.198 ms
Execution time : 1,607.899 ms