我有这个有26GB大小的WordPress表:
SELECT
*
FROM information_schema.TABLES
WHERE table_schema = "my_database"
AND table_name = "wpii_options";
结果:
{
"TABLE_CATALOG": "def",
"TABLE_SCHEMA": "my_database",
"TABLE_NAME": "wpii_options",
"TABLE_TYPE": "BASE TABLE",
"ENGINE": "InnoDB",
"VERSION": 10,
"ROW_FORMAT": "Compact",
"TABLE_ROWS": 13793552,
"AVG_ROW_LENGTH": 2025,
"DATA_LENGTH": 27932049408,
"MAX_DATA_LENGTH": 0,
"INDEX_LENGTH": 98304,
"DATA_FREE": 7340032,
"AUTO_INCREMENT": 16465,
"CREATE_TIME": "2016-07-26 04:28:08",
"UPDATE_TIME": null,
"CHECK_TIME": null,
"TABLE_COLLATION": "utf8_general_ci",
"CHECKSUM": null,
"CREATE_OPTIONS": "",
"TABLE_COMMENT": ""
}
用于启动" TABLE_ROWS"每次运行上述查询时,字段在10万到40万之间波动,但实际上行数并不多:
select count(*) from wpii_options;
结果:
292
但最重要的是我不知道26GB的使用位置:
show create table wpii_options;
结果:
CREATE TABLE `wpii_options` (
`option_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`option_name` varchar(191) NOT NULL DEFAULT '',
`option_value` longtext NOT NULL,
`autoload` varchar(20) NOT NULL DEFAULT 'yes',
PRIMARY KEY (`option_id`),
UNIQUE KEY `option_name` (`option_name`)
) ENGINE=InnoDB AUTO_INCREMENT=16465 DEFAULT CHARSET=utf8
检查每列的大小:
select
sum(length(option_id)) as option_id_length,
sum(length(option_name)) as option_name_length,
sum(length(option_value)) as option_value_length,
sum(length(autoload)) as autoload_length
from wpii_options;
结果:
{
"option_id_length": 816,
"option_name_length": 6533,
"option_value_length": 523982,
"autoload_length": 836
}
所以我的问题是:
答案 0 :(得分:0)
这解决了我的问题:
optimize table wpii_options;