Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/BenchmarkAnything/Storage/Backend/SQL/Query/common.pm |
Statements | Executed 44915 statements in 218ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
4650 | 1 | 1 | 51.2ms | 651ms | select_addvalue | BenchmarkAnything::Storage::Backend::SQL::Query::common::
4650 | 1 | 1 | 33.7ms | 676ms | select_addtyperelation | BenchmarkAnything::Storage::Backend::SQL::Query::common::
4650 | 1 | 1 | 28.0ms | 646ms | select_addtype | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 26.2ms | 251ms | select_raw_bench_bundle_for_processing | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 20.8ms | 406ms | select_raw_bench_bundle_for_lock | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 20.7ms | 230ms | select_benchmark_point_essentials | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 14.0ms | 180ms | select_benchmark | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 8.21ms | 673ms | update_raw_bench_bundle_set_processed | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 6.56ms | 534ms | select_complete_benchmark_point | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 6.36ms | 150ms | select_min_subsume_type | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1000 | 1 | 1 | 5.55ms | 335ms | start_processing_raw_bench_bundle | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1 | 1 | 1 | 12µs | 23.5ms | delete_processed_raw_bench_bundles | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1 | 1 | 1 | 8µs | 9µs | BEGIN@5 | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1 | 1 | 1 | 8µs | 146µs | BEGIN@9 | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1 | 1 | 1 | 6µs | 407µs | BEGIN@7 | BenchmarkAnything::Storage::Backend::SQL::Query::common::
1 | 1 | 1 | 4µs | 7µs | BEGIN@6 | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | _FOR_UPDATE | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | _NOW | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | benchmark_operators | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | copy_additional_values | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | copy_benchmark_backup_additional_relations | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | copy_benchmark_backup_value | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | create_period_check | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | create_where_clause | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | default_columns | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | delete_benchmark_additional_relations | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | delete_benchmark_value | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | insert_raw_bench_bundle | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_additional_key_id | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_additional_keys | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_addtype_by_name | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_benchmark_names | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_check_subsumed_values | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_count_datapointkeys | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_count_datapoints | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_count_keys | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_count_metrics | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_data_values_for_subsume | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_multiple_benchmark_points_additionals | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_multiple_benchmark_points_essentials | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_subsume_type | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | select_unit | BenchmarkAnything::Storage::Backend::SQL::Query::common::
0 | 0 | 0 | 0s | 0s | update_benchmark_backup_value | BenchmarkAnything::Storage::Backend::SQL::Query::common::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package BenchmarkAnything::Storage::Backend::SQL::Query::common; | ||||
2 | 1 | 300ns | our $AUTHORITY = 'cpan:TAPPER'; | ||
3 | # ABSTRACT: BenchmarkAnything::Storage::Backend::SQL - querying - backend base class | ||||
4 | 1 | 100ns | $BenchmarkAnything::Storage::Backend::SQL::Query::common::VERSION = '0.023'; | ||
5 | 2 | 16µs | 2 | 10µs | # spent 9µs (8+1) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@5 which was called:
# once (8µs+1µs) by base::import at line 5 # spent 9µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@5
# spent 1µs making 1 call to strict::import |
6 | 2 | 13µs | 2 | 9µs | # spent 7µs (4+2) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@6 which was called:
# once (4µs+2µs) by base::import at line 6 # spent 7µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@6
# spent 2µs making 1 call to warnings::import |
7 | 2 | 20µs | 2 | 407µs | # spent 407µs (6+401) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@7 which was called:
# once (6µs+401µs) by base::import at line 7 # spent 407µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@7
# spent 401µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 401µs |
8 | |||||
9 | 2 | 1.33ms | 2 | 284µs | # spent 146µs (8+138) within BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@9 which was called:
# once (8µs+138µs) by base::import at line 9 # spent 146µs making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::common::BEGIN@9
# spent 138µs making 1 call to Exporter::Tiny::import |
10 | |||||
11 | 1 | 200ns | my %h_used_selects; | ||
12 | 1 | 2µs | my %h_default_columns = ( | ||
13 | 'NAME' => 'b.bench', | ||||
14 | 'UNIT' => 'bu.bench_unit', | ||||
15 | 'VALUE' => 'bv.bench_value', | ||||
16 | 'VALUE_ID' => 'bv.bench_value_id', | ||||
17 | 'CREATED' => 'bv.created_at', | ||||
18 | ); | ||||
19 | |||||
20 | sub _NOW { "CURRENT_TIMESTAMP" } | ||||
21 | |||||
22 | sub _FOR_UPDATE { "FOR UPDATE" } | ||||
23 | |||||
24 | sub default_columns { | ||||
25 | return %h_default_columns; | ||||
26 | } | ||||
27 | |||||
28 | sub benchmark_operators { | ||||
29 | return ( '=', '!=', 'like', 'not like', '<', '>', '<=', '>=' ); | ||||
30 | } | ||||
31 | |||||
32 | sub create_where_clause { | ||||
33 | |||||
34 | my ( $or_self, $s_column_name, $ar_value ) = @_; | ||||
35 | |||||
36 | my $s_where_clause = q##; | ||||
37 | if ( $ar_value->[0] eq 'not like' ) { | ||||
38 | $s_where_clause = "$s_column_name NOT LIKE ?"; | ||||
39 | } | ||||
40 | elsif ( $ar_value->[0] eq 'like' ) { | ||||
41 | $s_where_clause = "$s_column_name LIKE ?"; | ||||
42 | } | ||||
43 | elsif ( | ||||
44 | $ar_value->[0] eq '<' | ||||
45 | || $ar_value->[0] eq '>' | ||||
46 | || $ar_value->[0] eq '<=' | ||||
47 | || $ar_value->[0] eq '>=' | ||||
48 | ) { | ||||
49 | $s_where_clause = "$s_column_name $ar_value->[0] ?"; | ||||
50 | } | ||||
51 | elsif ( $ar_value->[0] eq '=' ) { | ||||
52 | if ( $#{$ar_value} > 1 ) { | ||||
53 | $s_where_clause = "$s_column_name IN (" . (join ',', map {'?'} 2..@{$ar_value}) . ')'; | ||||
54 | } | ||||
55 | else { | ||||
56 | $s_where_clause = "$s_column_name = ?"; | ||||
57 | } | ||||
58 | } | ||||
59 | elsif ( $ar_value->[0] eq '!=' ) { | ||||
60 | if ( $#{$ar_value} > 1 ) { | ||||
61 | $s_where_clause = "$s_column_name NOT IN (" . (join ',', map {'?'} 2..@{$ar_value}) . ')'; | ||||
62 | } | ||||
63 | else { | ||||
64 | $s_where_clause = "$s_column_name != ?"; | ||||
65 | } | ||||
66 | } | ||||
67 | else { | ||||
68 | require Carp; | ||||
69 | Carp::confess("unknown operator '$ar_value->[0]'"); | ||||
70 | return; | ||||
71 | } | ||||
72 | |||||
73 | return $s_where_clause; | ||||
74 | |||||
75 | } | ||||
76 | |||||
77 | sub create_period_check { | ||||
78 | |||||
79 | my ( $or_self, $s_column, $dt_from, $dt_to ) = @_; | ||||
80 | |||||
81 | my @a_vals; | ||||
82 | my $s_where; | ||||
83 | if ( $dt_from ) { | ||||
84 | if ( my ( $s_date, $s_time ) = $dt_from =~ /(\d{4}-\d{2}-\d{2})( \d{2}:\d{2}:\d{2})?/ ) { | ||||
85 | $s_where .= "\nAND $s_column > ?"; | ||||
86 | push @a_vals, $s_date . ( $s_time || ' 00:00:00' ); | ||||
87 | } | ||||
88 | else { | ||||
89 | require Carp; | ||||
90 | Carp::confess(q#unknown date format for 'date_from'#); | ||||
91 | return; | ||||
92 | } | ||||
93 | } | ||||
94 | if ( $dt_to ) { | ||||
95 | if ( my ( $s_date, $s_time ) = $dt_to =~ /(\d{4}-\d{2}-\d{2})( \d{2}:\d{2}:\d{2})?/ ) { | ||||
96 | $s_where .= "\nAND $s_column < ?"; | ||||
97 | push @a_vals, $s_date . ( $s_time || ' 23:59:59' ); | ||||
98 | } | ||||
99 | else { | ||||
100 | require Carp; | ||||
101 | Carp::confess(q#unknown date format for 'date_to'#); | ||||
102 | return; | ||||
103 | } | ||||
104 | } | ||||
105 | |||||
106 | return { | ||||
107 | vals => \@a_vals, | ||||
108 | where => $s_where, | ||||
109 | }; | ||||
110 | |||||
111 | } | ||||
112 | |||||
113 | # spent 230ms (20.7+209) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark_point_essentials which was called 1000 times, avg 230µs/call:
# 1000 times (20.7ms+209ms) by BenchmarkAnything::Storage::Backend::SQL::get_single_benchmark_point at line 647 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 230µs/call | ||||
114 | |||||
115 | 1000 | 866µs | my ( $or_self, @a_vals ) = @_; | ||
116 | |||||
117 | 1000 | 7.69ms | 2000 | 211ms | return $or_self->execute_query( " # spent 209ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 209µs/call
# spent 2.05ms making 1000 calls to DBI::common::STORE, avg 2µs/call |
118 | SELECT | ||||
119 | b.bench, | ||||
120 | bv.created_at, | ||||
121 | bv.bench_value, | ||||
122 | bv.bench_value_id, | ||||
123 | bu.bench_unit | ||||
124 | FROM | ||||
125 | $or_self->{config}{tables}{benchmark_table} b | ||||
126 | JOIN | ||||
127 | $or_self->{config}{tables}{benchmark_value_table} bv | ||||
128 | ON | ||||
129 | b.bench_id = bv.bench_id | ||||
130 | LEFT JOIN | ||||
131 | $or_self->{config}{tables}{unit_table} bu | ||||
132 | ON | ||||
133 | b.bench_unit_id = bu.bench_unit_id | ||||
134 | WHERE | ||||
135 | bv.bench_value_id = ? | ||||
136 | ; | ||||
137 | ", @a_vals ); | ||||
138 | |||||
139 | } | ||||
140 | |||||
141 | # spent 534ms (6.56+527) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_complete_benchmark_point which was called 1000 times, avg 534µs/call:
# 1000 times (6.56ms+527ms) by BenchmarkAnything::Storage::Backend::SQL::get_single_benchmark_point at line 642 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 534µs/call | ||||
142 | |||||
143 | 1000 | 686µs | my ( $or_self, @a_vals ) = @_; | ||
144 | |||||
145 | 1000 | 738µs | my $query = " | ||
146 | SELECT | ||||
147 | bat.bench_additional_type, | ||||
148 | bav.bench_additional_value | ||||
149 | FROM | ||||
150 | benchs b | ||||
151 | JOIN | ||||
152 | bench_values bv | ||||
153 | ON | ||||
154 | b.bench_id = bv.bench_id | ||||
155 | JOIN | ||||
156 | bench_additional_type_relations batr | ||||
157 | ON | ||||
158 | bv.bench_id = batr.bench_id | ||||
159 | JOIN | ||||
160 | bench_additional_types bat | ||||
161 | ON | ||||
162 | batr.bench_additional_type_id = bat.bench_additional_type_id | ||||
163 | JOIN | ||||
164 | bench_additional_relations bar | ||||
165 | ON | ||||
166 | bv.bench_value_id = bar.bench_value_id | ||||
167 | JOIN | ||||
168 | bench_additional_values bav | ||||
169 | ON | ||||
170 | bar.bench_additional_value_id = bav.bench_additional_value_id AND | ||||
171 | bat.bench_additional_type_id = bav.bench_additional_type_id | ||||
172 | WHERE | ||||
173 | bv.bench_value_id = ? | ||||
174 | ORDER BY | ||||
175 | bat.bench_additional_type"; | ||||
176 | 1000 | 4.20ms | 2000 | 530ms | return $or_self->execute_query( $query, @a_vals ); # spent 527ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 527µs/call
# spent 2.63ms making 1000 calls to DBI::common::STORE, avg 3µs/call |
177 | } | ||||
178 | |||||
179 | sub select_multiple_benchmark_points_additionals { | ||||
180 | |||||
181 | my ( $or_self, $i_start, $i_count ) = @_; | ||||
182 | |||||
183 | my $i_to = $i_start + $i_count; | ||||
184 | |||||
185 | my $query = " | ||||
186 | SELECT | ||||
187 | bv.bench_value_id, | ||||
188 | bat.bench_additional_type, | ||||
189 | bav.bench_additional_value | ||||
190 | FROM | ||||
191 | benchs b | ||||
192 | JOIN | ||||
193 | bench_values bv | ||||
194 | ON | ||||
195 | b.bench_id = bv.bench_id | ||||
196 | JOIN | ||||
197 | bench_additional_type_relations batr | ||||
198 | ON | ||||
199 | bv.bench_id = batr.bench_id | ||||
200 | JOIN | ||||
201 | bench_additional_types bat | ||||
202 | ON | ||||
203 | batr.bench_additional_type_id = bat.bench_additional_type_id | ||||
204 | JOIN | ||||
205 | bench_additional_relations bar | ||||
206 | ON | ||||
207 | bv.bench_value_id = bar.bench_value_id | ||||
208 | JOIN | ||||
209 | bench_additional_values bav | ||||
210 | ON | ||||
211 | bar.bench_additional_value_id = bav.bench_additional_value_id AND | ||||
212 | bat.bench_additional_type_id = bav.bench_additional_type_id | ||||
213 | WHERE | ||||
214 | bv.bench_value_id >= ? AND | ||||
215 | bv.bench_value_id < ? | ||||
216 | ORDER BY | ||||
217 | bat.bench_additional_type"; | ||||
218 | return $or_self->execute_query( $query, $i_start, $i_to ); | ||||
219 | } | ||||
220 | |||||
221 | sub select_multiple_benchmark_points_essentials { | ||||
222 | |||||
223 | my ( $or_self, $i_start, $i_count ) = @_; | ||||
224 | |||||
225 | my $i_to = $i_start + $i_count; | ||||
226 | |||||
227 | return $or_self->execute_query( " | ||||
228 | SELECT | ||||
229 | b.bench, | ||||
230 | bv.created_at, | ||||
231 | bv.bench_value, | ||||
232 | bv.bench_value_id, | ||||
233 | bu.bench_unit | ||||
234 | FROM | ||||
235 | $or_self->{config}{tables}{benchmark_table} b | ||||
236 | JOIN | ||||
237 | $or_self->{config}{tables}{benchmark_value_table} bv | ||||
238 | ON | ||||
239 | b.bench_id = bv.bench_id | ||||
240 | LEFT JOIN | ||||
241 | $or_self->{config}{tables}{unit_table} bu | ||||
242 | ON | ||||
243 | b.bench_unit_id = bu.bench_unit_id | ||||
244 | WHERE | ||||
245 | bv.bench_value_id >= ? AND | ||||
246 | bv.bench_value_id < ? | ||||
247 | ; | ||||
248 | ", $i_start, $i_to ); | ||||
249 | |||||
250 | } | ||||
251 | |||||
252 | sub select_addtype_by_name { | ||||
253 | |||||
254 | my ( $or_self, @a_vals ) = @_; | ||||
255 | |||||
256 | return $or_self->execute_query( " | ||||
257 | SELECT bench_additional_type_id | ||||
258 | FROM $or_self->{config}{tables}{additional_type_table} | ||||
259 | WHERE bench_additional_type = ? | ||||
260 | ", @a_vals ); | ||||
261 | |||||
262 | } | ||||
263 | |||||
264 | # spent 150ms (6.36+144) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_min_subsume_type which was called 1000 times, avg 150µs/call:
# 1000 times (6.36ms+144ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 238 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 150µs/call | ||||
265 | |||||
266 | 1000 | 906µs | my ( $or_self, @a_vals ) = @_; | ||
267 | |||||
268 | 1000 | 4.91ms | 2000 | 146ms | return $or_self->execute_query( " # spent 144ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 144µs/call
# spent 1.81ms making 1000 calls to DBI::common::STORE, avg 2µs/call |
269 | SELECT bench_subsume_type_id | ||||
270 | FROM $or_self->{config}{tables}{subsume_type_table} | ||||
271 | ORDER BY bench_subsume_type_rank ASC | ||||
272 | LIMIT 1 | ||||
273 | " ); | ||||
274 | |||||
275 | } | ||||
276 | |||||
277 | sub select_subsume_type { | ||||
278 | |||||
279 | my ( $or_self, @a_vals ) = @_; | ||||
280 | |||||
281 | return $or_self->execute_query( " | ||||
282 | SELECT | ||||
283 | bench_subsume_type_id, | ||||
284 | bench_subsume_type_rank, | ||||
285 | datetime_strftime_pattern | ||||
286 | FROM | ||||
287 | $or_self->{config}{tables}{subsume_type_table} | ||||
288 | WHERE | ||||
289 | bench_subsume_type = ? | ||||
290 | ", @a_vals ); | ||||
291 | |||||
292 | } | ||||
293 | |||||
294 | sub select_check_subsumed_values { | ||||
295 | |||||
296 | my ( $or_self, $hr_vals ) = @_; | ||||
297 | |||||
298 | if (! $hr_vals->{subsume_type_id} ) { | ||||
299 | require Carp; | ||||
300 | Carp::confess(q#required parameter 'subsume_type_id' is missing#); | ||||
301 | return; | ||||
302 | } | ||||
303 | |||||
304 | my $hr_period_check = $or_self->create_period_check( | ||||
305 | 'bv.created_at', $hr_vals->{date_from}, $hr_vals->{date_to} | ||||
306 | ); | ||||
307 | |||||
308 | return $or_self->execute_query( | ||||
309 | " | ||||
310 | SELECT | ||||
311 | bv.bench_value_id | ||||
312 | FROM | ||||
313 | bench_values bv | ||||
314 | JOIN bench_subsume_types bet | ||||
315 | ON ( bv.bench_subsume_type_id = bet.bench_subsume_type_id ) | ||||
316 | WHERE | ||||
317 | bet.bench_subsume_type_rank > ( | ||||
318 | SELECT beti.bench_subsume_type_rank | ||||
319 | FROM bench_subsume_types beti | ||||
320 | WHERE bench_subsume_type_id = ? | ||||
321 | ) | ||||
322 | $hr_period_check->{where} | ||||
323 | LIMIT | ||||
324 | 1 | ||||
325 | ", | ||||
326 | $hr_vals->{subsume_type_id}, | ||||
327 | @{$hr_period_check->{vals}}, | ||||
328 | ); | ||||
329 | |||||
330 | } | ||||
331 | |||||
332 | sub select_data_values_for_subsume { | ||||
333 | |||||
334 | my ( $or_self, $hr_vals ) = @_; | ||||
335 | |||||
336 | my $hr_period_check = $or_self->create_period_check( | ||||
337 | 'bv.created_at', $hr_vals->{date_from}, $hr_vals->{date_to} | ||||
338 | ); | ||||
339 | |||||
340 | my @a_addexclude_vals; | ||||
341 | my $s_addexclude_where = q##; | ||||
342 | if ( $hr_vals->{exclude_additionals} && @{$hr_vals->{exclude_additionals}} ) { | ||||
343 | $s_addexclude_where = 'AND bav.bench_additional_type_id NOT IN (' . (join ',', map {'?'} @{$hr_vals->{exclude_additionals}}) . ')'; | ||||
344 | push @a_addexclude_vals, @{$hr_vals->{exclude_additionals}}; | ||||
345 | } | ||||
346 | |||||
347 | return $or_self->execute_query( | ||||
348 | " | ||||
349 | SELECT | ||||
350 | b.bench_id, | ||||
351 | bv.bench_value_id, | ||||
352 | bv.created_at, | ||||
353 | bv.bench_value, | ||||
354 | bet.bench_subsume_type_rank, | ||||
355 | GROUP_CONCAT( | ||||
356 | bav.bench_additional_type_id, | ||||
357 | '|', | ||||
358 | bav.bench_additional_value_id | ||||
359 | ORDER BY | ||||
360 | bav.bench_additional_type_id, | ||||
361 | bav.bench_additional_value_id | ||||
362 | SEPARATOR | ||||
363 | '-' | ||||
364 | ) AS additionals | ||||
365 | FROM | ||||
366 | benchs b | ||||
367 | JOIN bench_values bv | ||||
368 | ON ( bv.bench_id = b.bench_id ) | ||||
369 | JOIN bench_subsume_types bet | ||||
370 | ON ( bet.bench_subsume_type_id = bv.bench_subsume_type_id ) | ||||
371 | LEFT JOIN ( | ||||
372 | bench_additional_relations bar | ||||
373 | JOIN bench_additional_values bav | ||||
374 | ON ( bav.bench_additional_value_id = bar.bench_additional_value_id ) | ||||
375 | ) | ||||
376 | ON ( | ||||
377 | bar.active = 1 | ||||
378 | AND bar.bench_value_id = bv.bench_value_id | ||||
379 | $s_addexclude_where | ||||
380 | ) | ||||
381 | WHERE | ||||
382 | b.active = 1 | ||||
383 | AND bv.active = 1 | ||||
384 | $hr_period_check->{where} | ||||
385 | GROUP BY | ||||
386 | bet.bench_subsume_type_rank, | ||||
387 | b.bench_id, | ||||
388 | bv.created_at, | ||||
389 | bv.bench_value, | ||||
390 | bv.bench_value_id | ||||
391 | ORDER BY | ||||
392 | b.bench_id, | ||||
393 | additionals, | ||||
394 | bv.created_at | ||||
395 | ", | ||||
396 | @a_addexclude_vals, | ||||
397 | @{$hr_period_check->{vals}}, | ||||
398 | ); | ||||
399 | } | ||||
400 | |||||
401 | # spent 180ms (14.0+167) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_benchmark which was called 1000 times, avg 180µs/call:
# 1000 times (14.0ms+167ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 186 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 180µs/call | ||||
402 | |||||
403 | 1000 | 909µs | my ( $or_self, @a_vals ) = @_; | ||
404 | |||||
405 | 1000 | 6.43ms | 2000 | 169ms | return $or_self->execute_query( " # spent 167ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 167µs/call
# spent 1.98ms making 1000 calls to DBI::common::STORE, avg 2µs/call |
406 | SELECT bench_id | ||||
407 | FROM $or_self->{config}{tables}{benchmark_table} | ||||
408 | WHERE bench = ? | ||||
409 | ", @a_vals ); | ||||
410 | |||||
411 | } | ||||
412 | |||||
413 | sub select_benchmark_names { | ||||
414 | |||||
415 | my ( $or_self, @a_vals ) = @_; | ||||
416 | |||||
417 | my $query = " | ||||
418 | SELECT DISTINCT bench | ||||
419 | FROM $or_self->{config}{tables}{benchmark_table}"; | ||||
420 | $query .= " | ||||
421 | WHERE bench LIKE ? " if @a_vals; | ||||
422 | return $or_self->execute_query( $query, @a_vals ); | ||||
423 | |||||
424 | } | ||||
425 | |||||
426 | sub select_additional_keys { | ||||
427 | |||||
428 | my ( $or_self, @a_vals ) = @_; | ||||
429 | |||||
430 | my $query = " | ||||
431 | SELECT DISTINCT bench_additional_type | ||||
432 | FROM $or_self->{config}{tables}{additional_type_table}"; | ||||
433 | $query .= " | ||||
434 | WHERE bench_additional_type LIKE ? " if @a_vals; | ||||
435 | return $or_self->execute_query( $query, @a_vals ); | ||||
436 | |||||
437 | } | ||||
438 | |||||
439 | sub select_additional_key_id { | ||||
440 | |||||
441 | my ( $or_self, @a_vals ) = @_; | ||||
442 | |||||
443 | return $or_self->execute_query( " | ||||
444 | SELECT DISTINCT bench_additional_type_id | ||||
445 | FROM $or_self->{config}{tables}{additional_type_table} | ||||
446 | WHERE bench_additional_type = ? | ||||
447 | ", @a_vals ); | ||||
448 | |||||
449 | } | ||||
450 | |||||
451 | sub select_count_datapoints { | ||||
452 | my ( $or_self, @a_vals ) = @_; | ||||
453 | |||||
454 | return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{benchmark_value_table}" ); | ||||
455 | } | ||||
456 | |||||
457 | sub select_count_metrics { | ||||
458 | my ( $or_self, @a_vals ) = @_; | ||||
459 | |||||
460 | return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{benchmark_table}" ); | ||||
461 | } | ||||
462 | |||||
463 | sub select_count_keys { | ||||
464 | my ( $or_self, @a_vals ) = @_; | ||||
465 | |||||
466 | return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{additional_type_table}" ); | ||||
467 | } | ||||
468 | |||||
469 | sub select_count_datapointkeys { | ||||
470 | my ( $or_self, @a_vals ) = @_; | ||||
471 | |||||
472 | return $or_self->execute_query( "SELECT COUNT(1) FROM $or_self->{config}{tables}{additional_relation_table}" ); | ||||
473 | } | ||||
474 | |||||
475 | sub select_unit { | ||||
476 | |||||
477 | my ( $or_self, @a_vals ) = @_; | ||||
478 | |||||
479 | return $or_self->execute_query( " | ||||
480 | SELECT bench_unit_id | ||||
481 | FROM $or_self->{config}{tables}{unit_table} | ||||
482 | WHERE bench_unit = ? | ||||
483 | ", @a_vals ); | ||||
484 | |||||
485 | } | ||||
486 | |||||
487 | # spent 646ms (28.0+618) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtype which was called 4650 times, avg 139µs/call:
# 4650 times (28.0ms+618ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 274 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 139µs/call | ||||
488 | |||||
489 | 4650 | 3.15ms | my ( $or_self, @a_vals ) = @_; | ||
490 | |||||
491 | 4650 | 22.5ms | 9300 | 627ms | return $or_self->execute_query( " # spent 618ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 133µs/call
# spent 8.37ms making 4650 calls to DBI::common::STORE, avg 2µs/call |
492 | SELECT bench_additional_type_id | ||||
493 | FROM $or_self->{config}{tables}{additional_type_table} | ||||
494 | WHERE bench_additional_type = ? | ||||
495 | ", @a_vals ); | ||||
496 | |||||
497 | } | ||||
498 | |||||
499 | # spent 651ms (51.2+600) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_addvalue which was called 4650 times, avg 140µs/call:
# 4650 times (51.2ms+600ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 325 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 140µs/call | ||||
500 | |||||
501 | 4650 | 3.54ms | my ( $or_self, @a_vals ) = @_; | ||
502 | |||||
503 | 4650 | 69.0ms | 9300 | 608ms | return $or_self->execute_query( " # spent 600ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 129µs/call
# spent 8.08ms making 4650 calls to DBI::common::STORE, avg 2µs/call |
504 | SELECT bench_additional_value_id | ||||
505 | FROM $or_self->{config}{tables}{additional_value_table} | ||||
506 | WHERE bench_additional_type_id = ? AND bench_additional_value ".(defined($a_vals[1]) ? '= ?' : 'IS NULL')." | ||||
507 | ", @a_vals ); | ||||
508 | |||||
509 | } | ||||
510 | |||||
511 | # spent 676ms (33.7+642) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_addtyperelation which was called 4650 times, avg 145µs/call:
# 4650 times (33.7ms+642ms) by BenchmarkAnything::Storage::Backend::SQL::add_single_benchmark at line 304 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 145µs/call | ||||
512 | |||||
513 | 4650 | 3.72ms | my ( $or_self, @a_vals ) = @_; | ||
514 | |||||
515 | 4650 | 29.0ms | 9300 | 650ms | return $or_self->execute_query( " # spent 642ms making 4650 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 138µs/call
# spent 8.28ms making 4650 calls to DBI::common::STORE, avg 2µs/call |
516 | SELECT bench_id, bench_additional_type_id, created_at | ||||
517 | FROM $or_self->{config}{tables}{additional_type_relation_table} | ||||
518 | WHERE bench_id = ? AND bench_additional_type_id = ? | ||||
519 | ", @a_vals ); | ||||
520 | |||||
521 | } | ||||
522 | |||||
523 | sub insert_raw_bench_bundle { | ||||
524 | |||||
525 | my ( $or_self, @a_vals ) = @_; | ||||
526 | |||||
527 | return $or_self->execute_query( " | ||||
528 | INSERT INTO raw_bench_bundles | ||||
529 | (raw_bench_bundle_serialized) | ||||
530 | VALUES ( ? ) | ||||
531 | ", @a_vals ); | ||||
532 | |||||
533 | } | ||||
534 | |||||
535 | sub copy_benchmark_backup_value { | ||||
536 | |||||
537 | my ( $or_self, $hr_vals ) = @_; | ||||
538 | |||||
539 | for my $s_param (qw/ new_bench_value_id old_bench_value_id /) { | ||||
540 | if (! $hr_vals->{$s_param} ) { | ||||
541 | require Carp; | ||||
542 | Carp::confess("missing parameter '$s_param'"); | ||||
543 | return; | ||||
544 | } | ||||
545 | } | ||||
546 | |||||
547 | return $or_self->execute_query( " | ||||
548 | INSERT INTO $or_self->{config}{tables}{benchmark_backup_value_table} | ||||
549 | ( bench_value_id, bench_id, bench_subsume_type_id, bench_value, active, created_at ) | ||||
550 | SELECT | ||||
551 | ?, bench_id, bench_subsume_type_id, bench_value, active, created_at | ||||
552 | FROM | ||||
553 | $or_self->{config}{tables}{benchmark_value_table} | ||||
554 | WHERE | ||||
555 | bench_value_id = ? | ||||
556 | ", @{$hr_vals}{qw/ new_bench_value_id old_bench_value_id /} ); | ||||
557 | |||||
558 | } | ||||
559 | |||||
560 | sub copy_benchmark_backup_additional_relations { | ||||
561 | |||||
562 | my ( $or_self, $hr_vals ) = @_; | ||||
563 | |||||
564 | for my $s_param (qw/ new_bench_value_id old_bench_value_id /) { | ||||
565 | if (! $hr_vals->{$s_param} ) { | ||||
566 | require Carp; | ||||
567 | Carp::confess("missing parameter '$s_param'"); | ||||
568 | return; | ||||
569 | } | ||||
570 | } | ||||
571 | |||||
572 | return $or_self->execute_query( " | ||||
573 | INSERT INTO $or_self->{config}{tables}{backup_additional_relation_table} | ||||
574 | ( bench_backup_value_id, bench_additional_value_id, active, created_at ) | ||||
575 | SELECT | ||||
576 | ?, bench_additional_value_id, active, created_at | ||||
577 | FROM | ||||
578 | $or_self->{config}{tables}{additional_relation_table} | ||||
579 | WHERE | ||||
580 | bench_value_id = ? | ||||
581 | ", @{$hr_vals}{qw/ new_bench_value_id old_bench_value_id /} ); | ||||
582 | |||||
583 | } | ||||
584 | |||||
585 | sub update_benchmark_backup_value { | ||||
586 | |||||
587 | my ( $or_self, $hr_vals ) = @_; | ||||
588 | |||||
589 | return $or_self->execute_query( " | ||||
590 | UPDATE $or_self->{config}{tables}{benchmark_backup_value_table} | ||||
591 | SET bench_value_id = ? | ||||
592 | WHERE bench_value_id = ? | ||||
593 | ", @{$hr_vals}{qw/ | ||||
594 | new_bench_value_id | ||||
595 | old_bench_value_id | ||||
596 | /} ); | ||||
597 | |||||
598 | } | ||||
599 | |||||
600 | # spent 335ms (5.55+329) within BenchmarkAnything::Storage::Backend::SQL::Query::common::start_processing_raw_bench_bundle which was called 1000 times, avg 335µs/call:
# 1000 times (5.55ms+329ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 425 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 335µs/call | ||||
601 | |||||
602 | 1000 | 957µs | my ( $or_self, @a_vals ) = @_; | ||
603 | |||||
604 | 1000 | 3.94ms | 2000 | 331ms | return $or_self->execute_query( " # spent 329ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 329µs/call
# spent 2.08ms making 1000 calls to DBI::common::STORE, avg 2µs/call |
605 | UPDATE raw_bench_bundles | ||||
606 | SET processing = 1 | ||||
607 | WHERE raw_bench_bundle_id = ? | ||||
608 | ", @a_vals ); | ||||
609 | |||||
610 | } | ||||
611 | |||||
612 | # spent 673ms (8.21+665) within BenchmarkAnything::Storage::Backend::SQL::Query::common::update_raw_bench_bundle_set_processed which was called 1000 times, avg 673µs/call:
# 1000 times (8.21ms+665ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 441 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 673µs/call | ||||
613 | |||||
614 | 1000 | 1.09ms | my ( $or_self, @a_vals ) = @_; | ||
615 | |||||
616 | 1000 | 28.0ms | 2000 | 669ms | return $or_self->execute_query( " # spent 665ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 665µs/call
# spent 3.69ms making 1000 calls to DBI::common::STORE, avg 4µs/call |
617 | UPDATE raw_bench_bundles | ||||
618 | SET processed=1, | ||||
619 | processing=0 | ||||
620 | WHERE raw_bench_bundle_id = ? | ||||
621 | ", @a_vals ); | ||||
622 | |||||
623 | } | ||||
624 | |||||
625 | sub delete_benchmark_additional_relations { | ||||
626 | |||||
627 | my ( $or_self, @a_vals ) = @_; | ||||
628 | |||||
629 | return $or_self->execute_query( " | ||||
630 | DELETE FROM $or_self->{config}{tables}{additional_relation_table} | ||||
631 | WHERE bench_value_id = ? | ||||
632 | ", @a_vals ); | ||||
633 | |||||
634 | } | ||||
635 | |||||
636 | sub delete_benchmark_value { | ||||
637 | |||||
638 | my ( $or_self, @a_vals ) = @_; | ||||
639 | |||||
640 | return $or_self->execute_query( " | ||||
641 | DELETE FROM $or_self->{config}{tables}{benchmark_value_table} | ||||
642 | WHERE bench_value_id = ? | ||||
643 | ", @a_vals ); | ||||
644 | |||||
645 | } | ||||
646 | |||||
647 | # Garbage Collection | ||||
648 | # spent 23.5ms (12µs+23.5) within BenchmarkAnything::Storage::Backend::SQL::Query::common::delete_processed_raw_bench_bundles which was called:
# once (12µs+23.5ms) by BenchmarkAnything::Storage::Backend::SQL::gc at line 455 of BenchmarkAnything/Storage/Backend/SQL.pm | ||||
649 | |||||
650 | 1 | 500ns | my ( $or_self, @a_vals ) = @_; | ||
651 | |||||
652 | 1 | 11µs | 2 | 23.5ms | return $or_self->execute_query( " # spent 23.5ms making 1 call to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query
# spent 9µs making 1 call to DBI::common::STORE |
653 | DELETE FROM raw_bench_bundles | ||||
654 | WHERE processed=1 AND | ||||
655 | processing=0 | ||||
656 | ", @a_vals ); | ||||
657 | |||||
658 | } | ||||
659 | |||||
660 | sub copy_additional_values { | ||||
661 | |||||
662 | my ( $or_self, $hr_vals ) = @_; | ||||
663 | |||||
664 | for my $s_param (qw/ new_bench_value_id old_bench_value_id /) { | ||||
665 | if (! $hr_vals->{$s_param} ) { | ||||
666 | require Carp; | ||||
667 | Carp::confess("missing parameter '$s_param'"); | ||||
668 | return; | ||||
669 | } | ||||
670 | } | ||||
671 | |||||
672 | return $or_self->execute_query( " | ||||
673 | INSERT INTO $or_self->{config}{tables}{additional_relation_table} | ||||
674 | ( bench_value_id, bench_additional_value_id, active, created_at ) | ||||
675 | SELECT | ||||
676 | ?, bench_additional_value_id, 1, @{[$or_self->_NOW]} | ||||
677 | FROM | ||||
678 | $or_self->{config}{tables}{additional_relation_table} | ||||
679 | WHERE | ||||
680 | bench_value_id = ? | ||||
681 | ", @{$hr_vals}{qw/ new_bench_value_id old_bench_value_id /} ); | ||||
682 | |||||
683 | } | ||||
684 | |||||
685 | # spent 406ms (20.8+385) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_lock which was called 1000 times, avg 406µs/call:
# 1000 times (20.8ms+385ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 417 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 406µs/call | ||||
686 | |||||
687 | 1000 | 1.06ms | my ( $or_self, @a_vals ) = @_; | ||
688 | |||||
689 | 1000 | 11.1ms | 3000 | 387ms | return $or_self->execute_query( " # spent 383ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 383µs/call
# spent 2.42ms making 1000 calls to DBI::common::STORE, avg 2µs/call
# spent 2.21ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_FOR_UPDATE, avg 2µs/call |
690 | SELECT raw_bench_bundle_id | ||||
691 | FROM raw_bench_bundles | ||||
692 | WHERE processed=0 AND | ||||
693 | processing=0 | ||||
694 | ORDER BY raw_bench_bundle_id ASC | ||||
695 | LIMIT 1 | ||||
696 | @{[$or_self->_FOR_UPDATE]} | ||||
697 | ", @a_vals ); | ||||
698 | } | ||||
699 | |||||
700 | # spent 251ms (26.2+224) within BenchmarkAnything::Storage::Backend::SQL::Query::common::select_raw_bench_bundle_for_processing which was called 1000 times, avg 251µs/call:
# 1000 times (26.2ms+224ms) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 435 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 251µs/call | ||||
701 | |||||
702 | 1000 | 1.41ms | my ( $or_self, @a_vals ) = @_; | ||
703 | |||||
704 | 1000 | 10.8ms | 3000 | 227ms | return $or_self->execute_query( " # spent 222ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::execute_query, avg 222µs/call
# spent 2.20ms making 1000 calls to DBI::common::STORE, avg 2µs/call
# spent 2.07ms making 1000 calls to BenchmarkAnything::Storage::Backend::SQL::Query::mysql::_FOR_UPDATE, avg 2µs/call |
705 | SELECT raw_bench_bundle_serialized | ||||
706 | FROM raw_bench_bundles | ||||
707 | WHERE raw_bench_bundle_id = ? | ||||
708 | LIMIT 1 | ||||
709 | @{[$or_self->_FOR_UPDATE]} | ||||
710 | ", @a_vals ); | ||||
711 | } | ||||
712 | |||||
713 | 1 | 4µs | 1; | ||
714 | |||||
715 | __END__ |