帮助 Kohana 3 ORM 加快一点速度
我注意到,当我开始使用它们时,Kohana 3 ORM 会为每个模型运行“显示完整列”:
SHOW FULL COLUMNS FROM `mytable`
此查询可能需要几个时钟周期来执行(在 Kohana 分析器中,它实际上是我当前运行的所有查询中最慢的)应用程序)。
有没有办法通过禁用此行为并在我的模型中显式定义列来帮助 Kohana 3 ORM 加速?
I noticed that Kohana 3 ORM runs a "SHOW FULL COLUMNS" for each of my models when I start using them:
SHOW FULL COLUMNS FROM `mytable`
This query might take a few clock cycles to execute (in the Kohana profiler it's actually the slowest of all queries ran in my current app).
Is there a way to help Kohana 3 ORM to speed up by disabling this behaviour and explicitly define the columns in my models instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
biakaveron 用评论回答了我的问题,所以我不能排除正确的答案。
摘自 Kohana 官方论坛上 Wouters 的回答(biakaveron 指出的地方),这是正确的答案:
biakaveron answered my question with a comment so I can't except the correct answer.
Taken from Wouters answer on the official Kohana forums (where biakaveron pointed to), this is the correct answer:
执行该查询时不会有太多开销;尽管您可以通过手动定义它们来缓存它们/跳过该过程(如果这确实是您想要覆盖模型中的
$_table_columns
的内容,但我不知道您可以节省多少时间) - 值得尝试)。我提出了
list_columns()
的缓存替代方案,但它被拒绝了,因为它实际上并不是那么大的瓶颈:There isn't too much overhead when that query gets executed; though you can cache them / skip the process by defining them manually (if that is really what you want override the
$_table_columns
in your models, though I don't see how much time you can save doing it - it's worth trying).I proposed a caching alternative for
list_columns()
but it got denied as it really isn't that much of a bottleneck: http://dev.kohanaframework.org/issues/2848不要忘记下划线:
这将为您提供完整的专栏
信息作为数组:
do not forget underscore:
This will give you full column
info as an array:
不知道 kohana 团队如何说“显示完整列”在所有情况下都可以从缓存中快速读取。对于我们的工作负载来说,查询缓存是 mysql 的瓶颈。所以我们不得不把它关掉。
https://blogs.oracle.com/dlutz/entry/mysql_query_cache_sizing
显示完整的证明columns 是运行次数最多的查询
https://www.dropbox .com/s/zn0pbiogt774ne4/Screenshot%202015-02-17%2018.56.21.png?dl=0
来自 NewRelic mysql 插件的磁盘上临时表的证明。
https://www.dropbox .com/s/cwo09sy9qxboeds/Screenshot%202015-02-17%2019.00.19.png?dl=0
最有问题的查询(> 100ms)按查询计数排序。
https://www.dropbox .com/s/a1kpmkef4jd8uvt/Screenshot%202015-02-17%2018.55.38.png?dl=0
Not sure how the kohana team said 'show full columns' runs as fast reading from cache for all cases. Query cache is a bottleneck on mysql for our workload due to . So we had to turn it off.
https://blogs.oracle.com/dlutz/entry/mysql_query_cache_sizing
Proof that show full columns is the most run query
https://www.dropbox.com/s/zn0pbiogt774ne4/Screenshot%202015-02-17%2018.56.21.png?dl=0
Proof of the temp tables on the disk from NewRelic mysql plugin.
https://www.dropbox.com/s/cwo09sy9qxboeds/Screenshot%202015-02-17%2019.00.19.png?dl=0
And the top offending queries (> 100ms) sorted by query count.
https://www.dropbox.com/s/a1kpmkef4jd8uvt/Screenshot%202015-02-17%2018.55.38.png?dl=0