Check and Analyze The STATISTICS in The MySQL Database Smart Way of Technology
Check and Analyze The STATISTICS in The MySQL Database Smart Way of Technology
Worked in Database technology for �xed the issues faced in daily activities in Oracle, MS SQL Server, MySQL, MariaDB etc.
Example:
mysql> ANALYZE TABLE city;
+------------+---------+----------+----------+
Note: Read last note with example for ANALYZE table make it Uninitialized and run stats on next table access.
ANALYZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name UPDATE HISTOGRAM ON col_name [, col_name] ..[WITH N BUCKETS]
Example:
Table: world.city
Op: histogram
Msg_type: status
Example:
mysql> ANALYZE TABLE city DROP HISTOGRAM ON District;
+------------+-----------+----------+-----------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+------------+-----------+----------+-----------------------------------------------------+
| world.city | histogram | status | Histogram statistics removed for column 'District'. |
+------------+-----------+----------+-----------------------------------------------------+
SELECT HISTOGRAM FROM INFORMATION_SCHEMA.COLUMN_STATISTICS WHERE TABLE_NAME = 'city' AND COLUMN_NAME = 'name';
Note:
ANALYZE TABLE clears table statistics from the INFORMATION_SCHEMA.INNODB_TABLESTATS table and
sets the STATS_INITIALIZED column to Uninitialized.
Statistics are collected again the next time the table is accessed.
Example of Note:
------+
| TABLE_ID | NAME | STATS_INITIALIZED | NUM_ROWS | CLUST_INDEX_SIZE | OTHER_INDEX_SIZE | MODIFIED_COUNTER | AUTOINC |
REF_COUNT |
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
| 1088 | world/city | Initialized | 4188 | 25 | 8 | 0 | 4080 |
2 |
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
+------------+---------+----------+----------+
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
| 1088 | world/city | Uninitialized | 0 | 0 | 0 | 0 | 4080 |
1 |
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
1 row in set (0.00 sec)
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
| TABLE_ID | NAME | STATS_INITIALIZED | NUM_ROWS | CLUST_INDEX_SIZE | OTHER_INDEX_SIZE | MODIFIED_COUNTER | AUTOINC |
REF_COUNT |
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
| 1088 | world/city | Initialized | 4188 | 25 | 8 | 0 | 4080 |
2 |
+----------+------------+-------------------+----------+------------------+------------------+------------------+---------+--
------+
This site uses Akismet to reduce spam. Learn how your comment data is processed.