Add mechanism to refresh data about Database

Created on 2 September 2025, about 1 month ago

Problem/Motivation

The Xray Audit module uses the SQL command SHOW TABLE STATUS to retrieve database table information for its reports. However, SHOW TABLE STATUS returns cached data maintained by the MySQL/MariaDB engine for performance reasons.

As a result, when changes are made to the database—such as cleaning up orphaned revisions or optimizing tables—the Xray Audit report may continue to display outdated table size and row count information until the internal cache is refreshed.

This causes inconsistency in the reported data and may mislead site administrators who rely on these reports for maintenance and auditing purposes.

It would be great to show only two decimal places.

Steps to reproduce

  • Install and enable the Xray Audit module.
  • View the database table status report provided by the module.
  • Perform a database-altering operation (e.g., delete orphaned node revisions or manually truncate a table).
  • Revisit the Xray Audit report.
  • Observe that the table size, row count, or other metrics have not updated, even though the underlying data has changed.

Proposed resolution

Implement a mechanism in the Xray Audit module to allow manual or periodic refresh of table statistics.

Possible technical solutions:

  • Run the SQL command ANALYZE TABLE for relevant tables before executing SHOW TABLE STATUS. This will refresh the cached statistics.
  • Add a cron hook to periodically update statistics using ANALYZE TABLE.
  • Provide a UI button or Drush command to manually trigger a refresh of table statistics.
  • Ensure permissions and performance considerations are accounted for, as ANALYZE TABLE may lock tables briefly.

Note: Not all database engines may support ANALYZE TABLE in the same way. Implement a database-driver-aware solution or restrict the feature to MySQL/MariaDB.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain lpeidro Madrid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024