我遇到了一些问题,重复查询减慢了渲染 HTML 表的速度(while 循环内的选择查询非常相似)。所以我创建了一些简单的缓存函数(php):
check_cache()
write_cache()
return_cache()
这些函数防止服务器从数据库中询问任何东西。 这大大加快了速度!
后来看到MySQL缓存了SELECT语句:
The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again.
如果 MySQL 已经这样做,为什么这会提高性能?
最佳答案
可能的问题
1) 如果您的应用程序频繁更新表,那么查询缓存将不断被清除,您将不会从中获得任何好处。
2)分区表不支持查询缓存。
3)查询缓存在您有多个 mysqld 服务器更新相同 MyISAM 表的环境中不起作用。
4)SELECT 语句应该相同。
关于php - MySQL 查询缓存与自定义缓存功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35727681/