额外查询负载CakePHP [英] loads of extra queries CakePHP
问题描述
340我现在正在重建一个cakephp构建,试图找出什么占用所有额外的时间和ram等,现在我只是想了解这里发生了什么
我发现在每个页面加载都有类似这样的30-40个mysql调用:
SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME =?;
我不能真正地找到为什么,那是,这是东西需要蛋糕或老程序员是否喜欢风扇,还是这就像什么?
---------------编辑---- -------------
我现在已将问题查询定位到
a核心文件:
lib / Cake / Model / Datasource / Database / mysql.php
和函数:
getCharsetName($ name)
但我找不到在哪里或为什么这叫
解决方案听起来像是架构缓存被禁用,或者由于某种原因而无法工作。
检查
Model :: $ cacheSources
,理想情况下应该是true
。如果它已经是true
,那么你需要做一些进一步的调试,检查从getCharsetName()
正在被调用,例如通过异常stacktrace:$ e = new Exception
debug($ e-> getTraceAsString());
也许你的应用程序显式调用方法,谁知道。还要检查为
$ name
参数传递的内容。
并确保
tmp / cache / models /
是可写的,可读的。340I'm rebuilding a cakephp build at the moment and trying to figure out what's taking all the extra time and ram and so on, right now I'm just trying to understand what's happening here
I've found that there are like 30-40 mysql-calls like this on every page load:
SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?;
and I can't really find why and where that is, is this something needed for cake or has the old programmer shit the fan or is this just like "whatever"?
--------------- EDIT -----------------
I have now located the query in question to a core file:
lib/Cake/Model/Datasource/Database/mysql.php
and the function:
getCharsetName ($name)
however I can't find where or why this is called
解决方案Sounds like schema caching is disabled, or not working for some reason.
Check
Model::$cacheSources
, ideally it should betrue
. If it already istrue
, then you'll need to do some further debugging, check from where exactlygetCharsetName()
is being called, for example via exception stacktrace:$e = new Exception(); debug($e->getTraceAsString());
Maybe your application is explicitly invoking the method, who knows. Also check what is passed for the
$name
parameter.And make sure that
/tmp/cache/models/
is writable as well as readable.这篇关于额外查询负载CakePHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!