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