php - MySQL 查询缓存与自定义缓存功能

标签 php mysql caching

我遇到了一些问题,重复查询减慢了渲染 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/

相关文章:

php - 返回的数组索引使用记录 ID 而不是行数

asp.net-mvc - 在 MVC 应用程序中配置 NHibernate 二级缓存

php - 在 PHP 中获取 webroot

php - Paypal响应码——如何正确处理

php - 如何在Windows上为PHP7.0编译PECL扩展win32service

如果月份相同,PHP 将得到相同行的结果

php - 使用 enum mysql php 切换按钮值

c# - 为什么使用MySqlDataAdapter时DataTableReader会丢失数据?

.htaccess - 当用户使用鼠标或键盘进行回击时,Safari 似乎会忽略缓存设置

javascript - service worker 缓存需要时间来响应延迟