脏页比例是通过Innodb_buffer_pool_pages_dirty/Innodb_buffer_pool_pages_total得到 的 mysql怎么查看
时间: 2023-07-30 14:05:06 浏览: 150
浅析在线调整 innodb_buffer_pool_size
你可以使用以下命令来查看InnoDB缓冲池的脏页比例:
```
show global status like 'Innodb_buffer_pool_pages_dirty';
show global status like 'Innodb_buffer_pool_pages_total';
```
这将会返回脏页数和总页数,然后你可以计算脏页比例。或者你可以使用以下命令一次性查询:
```
SELECT CONCAT(ROUND((SUM(dirty_pages) / SUM(total_pages)) * 100, 2), '%') AS `Dirty Pages Ratio`
FROM (
SELECT variable_name, variable_value,
CASE WHEN variable_name = 'Innodb_buffer_pool_pages_total' THEN variable_value ELSE 0 END AS total_pages,
CASE WHEN variable_name = 'Innodb_buffer_pool_pages_dirty' THEN variable_value ELSE 0 END AS dirty_pages
FROM information_schema.GLOBAL_STATUS
WHERE variable_name IN ('Innodb_buffer_pool_pages_total', 'Innodb_buffer_pool_pages_dirty')
) AS a;
```
这将返回一个类似于以下内容的结果:
```
+-----------------+
| Dirty Pages Ratio |
+-----------------+
| 0.03% |
+-----------------+
```
这里的脏页比例为0.03%。
阅读全文