MySQL 8.3.0
Source Code Documentation
aggregated_stats_buffer.h
Go to the documentation of this file.
1/* Copyright (c) 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef AGGREGATED_STATS_BUFFER_H
24#define AGGREGATED_STATS_BUFFER_H
25
26#include <atomic>
27#include "include/my_sqlcommand.h" // SQLCOM_END
28
29/**
30 Similar to System_status_var, implements atomic counters for status variables
31 whose values are calculated by aggregating over all available sessions
32 (THDs). The single buffer object will store aggregated values for a number of
33 THDs belonging to the same shard.
34 All counters must use the same atomic data type, to simplify working with
35 offsets.
36
37 This mechanism is used to maintain these values in real-time for the purpose
38 of reporting telemetry metrics. Existing older mechanism to calculate the
39 same data on-demand (for SHOW GLOBAL STATUS) was not modified.
40*/
43 void flush();
45 uint64_t get_counter(std::size_t offset);
46
47 std::atomic_uint64_t com_other;
48 std::atomic_uint64_t com_stmt_execute;
49 std::atomic_uint64_t com_stmt_close;
50 std::atomic_uint64_t com_stmt_fetch;
51 std::atomic_uint64_t com_stmt_prepare;
52 std::atomic_uint64_t com_stmt_reset;
53 std::atomic_uint64_t com_stmt_reprepare;
54 std::atomic_uint64_t com_stmt_send_long_data;
55 std::atomic_uint64_t com_stat[(unsigned int)SQLCOM_END];
56
57 std::atomic_uint64_t table_open_cache_hits;
58 std::atomic_uint64_t table_open_cache_misses;
59 std::atomic_uint64_t table_open_cache_overflows;
60 std::atomic_uint64_t created_tmp_disk_tables;
61 std::atomic_uint64_t created_tmp_tables;
62 std::atomic_uint64_t max_execution_time_exceeded;
63 std::atomic_uint64_t max_execution_time_set;
64 std::atomic_uint64_t max_execution_time_set_failed;
65 std::atomic_uint64_t opened_tables;
66 std::atomic_uint64_t opened_shares;
67 std::atomic_uint64_t questions;
69 std::atomic_uint64_t select_full_join_count;
70 std::atomic_uint64_t select_full_range_join_count;
71 std::atomic_uint64_t select_range_count;
72 std::atomic_uint64_t select_range_check_count;
73 std::atomic_uint64_t select_scan_count;
74 std::atomic_uint64_t long_query_count;
75 std::atomic_uint64_t filesort_merge_passes;
76 std::atomic_uint64_t filesort_range_count;
77 std::atomic_uint64_t filesort_rows;
78 std::atomic_uint64_t filesort_scan_count;
79 std::atomic_uint64_t bytes_sent;
80 std::atomic_uint64_t bytes_received;
81
82 std::atomic_uint64_t ha_commit_count;
83 std::atomic_uint64_t ha_delete_count;
84 std::atomic_uint64_t ha_discover_count;
85 std::atomic_uint64_t ha_external_lock_count;
86 std::atomic_uint64_t ha_multi_range_read_init_count;
87 std::atomic_uint64_t ha_prepare_count;
88 std::atomic_uint64_t ha_read_first_count;
89 std::atomic_uint64_t ha_read_key_count;
90 std::atomic_uint64_t ha_read_last_count;
91 std::atomic_uint64_t ha_read_next_count;
92 std::atomic_uint64_t ha_read_prev_count;
93 std::atomic_uint64_t ha_read_rnd_count;
94 std::atomic_uint64_t ha_read_rnd_next_count;
95 std::atomic_uint64_t ha_rollback_count;
96 std::atomic_uint64_t ha_savepoint_count;
97 std::atomic_uint64_t ha_savepoint_rollback_count;
98 std::atomic_uint64_t ha_update_count;
99 std::atomic_uint64_t ha_write_count;
100};
101
102#endif /* AGGREGATED_STATS_BUFFER_H */
@ SQLCOM_END
Definition: my_sqlcommand.h:207
Similar to System_status_var, implements atomic counters for status variables whose values are calcul...
Definition: aggregated_stats_buffer.h:41
std::atomic_uint64_t table_open_cache_misses
Definition: aggregated_stats_buffer.h:58
std::atomic_uint64_t max_execution_time_set_failed
Definition: aggregated_stats_buffer.h:64
std::atomic_uint64_t com_stmt_fetch
Definition: aggregated_stats_buffer.h:50
std::atomic_uint64_t bytes_sent
Definition: aggregated_stats_buffer.h:79
std::atomic_uint64_t select_range_count
Definition: aggregated_stats_buffer.h:71
std::atomic_uint64_t ha_update_count
Definition: aggregated_stats_buffer.h:98
std::atomic_uint64_t com_stmt_prepare
Definition: aggregated_stats_buffer.h:51
std::atomic_uint64_t questions
Definition: aggregated_stats_buffer.h:67
std::atomic_uint64_t ha_read_rnd_next_count
Definition: aggregated_stats_buffer.h:94
std::atomic_uint64_t ha_discover_count
Definition: aggregated_stats_buffer.h:84
std::atomic_uint64_t ha_read_first_count
Definition: aggregated_stats_buffer.h:88
std::atomic_uint64_t filesort_range_count
Definition: aggregated_stats_buffer.h:76
std::atomic_uint64_t table_open_cache_hits
Definition: aggregated_stats_buffer.h:57
std::atomic_uint64_t com_stmt_execute
Definition: aggregated_stats_buffer.h:48
std::atomic_uint64_t com_stmt_close
Definition: aggregated_stats_buffer.h:49
std::atomic_uint64_t ha_read_rnd_count
Definition: aggregated_stats_buffer.h:93
std::atomic_uint64_t ha_read_last_count
Definition: aggregated_stats_buffer.h:90
std::atomic_uint64_t bytes_received
Definition: aggregated_stats_buffer.h:80
std::atomic_uint64_t ha_prepare_count
Definition: aggregated_stats_buffer.h:87
std::atomic_uint64_t com_stmt_send_long_data
Definition: aggregated_stats_buffer.h:54
std::atomic_uint64_t com_stat[(unsigned int) SQLCOM_END]
Definition: aggregated_stats_buffer.h:55
std::atomic_uint64_t filesort_scan_count
Definition: aggregated_stats_buffer.h:78
std::atomic_uint64_t ha_read_next_count
Definition: aggregated_stats_buffer.h:91
std::atomic_uint64_t created_tmp_disk_tables
Definition: aggregated_stats_buffer.h:60
void flush()
Definition: aggregated_stats_buffer.cc:28
std::atomic_uint64_t ha_external_lock_count
Definition: aggregated_stats_buffer.h:85
std::atomic_uint64_t ha_savepoint_count
Definition: aggregated_stats_buffer.h:96
std::atomic_uint64_t select_full_range_join_count
Definition: aggregated_stats_buffer.h:70
std::atomic_uint64_t opened_shares
Definition: aggregated_stats_buffer.h:66
uint64_t get_counter(std::size_t offset)
Definition: aggregated_stats_buffer.cc:137
std::atomic_uint64_t table_open_cache_overflows
Definition: aggregated_stats_buffer.h:59
std::atomic_uint64_t ha_write_count
Definition: aggregated_stats_buffer.h:99
std::atomic_uint64_t com_stmt_reprepare
Definition: aggregated_stats_buffer.h:53
std::atomic_uint64_t ha_read_prev_count
Definition: aggregated_stats_buffer.h:92
std::atomic_uint64_t ha_read_key_count
Definition: aggregated_stats_buffer.h:89
std::atomic_uint64_t max_execution_time_exceeded
Definition: aggregated_stats_buffer.h:62
std::atomic_uint64_t com_other
Definition: aggregated_stats_buffer.h:47
aggregated_stats_buffer()
Definition: aggregated_stats_buffer.cc:26
std::atomic_uint64_t filesort_merge_passes
Definition: aggregated_stats_buffer.h:75
std::atomic_uint64_t secondary_engine_execution_count
Definition: aggregated_stats_buffer.h:68
std::atomic_uint64_t opened_tables
Definition: aggregated_stats_buffer.h:65
std::atomic_uint64_t created_tmp_tables
Definition: aggregated_stats_buffer.h:61
std::atomic_uint64_t select_range_check_count
Definition: aggregated_stats_buffer.h:72
std::atomic_uint64_t ha_commit_count
Definition: aggregated_stats_buffer.h:82
std::atomic_uint64_t long_query_count
Definition: aggregated_stats_buffer.h:74
std::atomic_uint64_t ha_rollback_count
Definition: aggregated_stats_buffer.h:95
std::atomic_uint64_t ha_savepoint_rollback_count
Definition: aggregated_stats_buffer.h:97
std::atomic_uint64_t select_full_join_count
Definition: aggregated_stats_buffer.h:69
std::atomic_uint64_t filesort_rows
Definition: aggregated_stats_buffer.h:77
void add_from(aggregated_stats_buffer &shard)
Definition: aggregated_stats_buffer.cc:82
std::atomic_uint64_t select_scan_count
Definition: aggregated_stats_buffer.h:73
std::atomic_uint64_t ha_delete_count
Definition: aggregated_stats_buffer.h:83
std::atomic_uint64_t com_stmt_reset
Definition: aggregated_stats_buffer.h:52
std::atomic_uint64_t ha_multi_range_read_init_count
Definition: aggregated_stats_buffer.h:86
std::atomic_uint64_t max_execution_time_set
Definition: aggregated_stats_buffer.h:63