Skip to content

Commit 4ef86ba

Browse files
authored
Switch table rows stats query over to performance_schema (DataDog#20702)
* Switch table rows stats query over to performance_schema * add changelog
1 parent c6cc2f8 commit 4ef86ba

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

mysql/changelog.d/20702.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switch table rows stats query from information_schema to performance_schema

mysql/datadog_checks/mysql/mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def _collect_metrics(self, db, tags):
649649
results['information_schema_size'] = self._query_size_per_schema(db)
650650
metrics.update(SCHEMA_VARS)
651651

652-
if is_affirmative(self._config.options.get('table_rows_stats_metrics', False)) and self.userstat_enabled:
652+
if self._config.table_rows_stats_enabled and self.userstat_enabled:
653653
# report size of tables in MiB to Datadog
654654
self.log.debug("Collecting Table Row Stats Metrics.")
655655
with tracked_query(self, operation="table_rows_stats_metrics"):

mysql/datadog_checks/mysql/queries.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
LIMIT 1"""
1414

1515
SQL_QUERY_TABLE_ROWS_STATS = """\
16-
SELECT table_schema, table_name, rows_read, rows_changed
17-
FROM information_schema.table_statistics"""
16+
SELECT
17+
OBJECT_SCHEMA as table_schema,
18+
OBJECT_NAME as table_name,
19+
COUNT_READ as rows_read,
20+
COUNT_WRITE as rows_changed
21+
FROM performance_schema.table_io_waits_summary_by_table
22+
WHERE OBJECT_SCHEMA NOT IN ('mysql', 'performance_schema', 'information_schema')"""
1823

1924
SQL_QUERY_SCHEMA_SIZE = """\
2025
SELECT table_schema, IFNULL(SUM(data_length+index_length)/1024/1024,0) AS total_mb

0 commit comments

Comments
 (0)