WordPress at Your Fingertips
function is not described

WP_Debug_Data::get_database_size() public WP 5.2.0

Fetch the total size of all the database tables for the active database user.

{} It's a method of the class: WP_Debug_Data{}

No Hooks.

Return

Int. The size of the database, in bytes.

Usage

$result = WP_Debug_Data::get_database_size();

Changelog

Since 5.2.0 Introduced.

Code of WP_Debug_Data::get_database_size() WP 5.8.2

public static function get_database_size() {
	global $wpdb;
	$size = 0;
	$rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );

	if ( $wpdb->num_rows > 0 ) {
		foreach ( $rows as $row ) {
			$size += $row['Data_length'] + $row['Index_length'];
		}
	}

	return (int) $size;
}