WP_Debug_Data::get_database_size() WordPress Method

The WP_Debug_Data::get_database_size() method is used to get the size of the WordPress database. This is useful for debugging purposes.

WP_Debug_Data::get_database_size() #

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


Return

(int) The size of the database, in bytes.


Top ↑

Source

File: wp-admin/includes/class-wp-debug-data.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.