帮助Kohana 3 ORM加快一点速度 [英] Helping Kohana 3 ORM to speed up a little

查看:85
本文介绍了帮助Kohana 3 ORM加快一点速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始使用它们时,我注意到Kohana 3 ORM为我的每个模型运行一个"SHOW FULL COLUMNS":

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`

此查询可能需要几个时钟周期才能执行(在Kohana分析器中,这实际上是我当前应用中运行的所有查询中最慢的).

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).

是否有一种方法可以通过禁用此行为并在模型中显式定义列来帮助Kohana 3 ORM加速运行?

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?

推荐答案

biakaveron 用评论回答了我的问题,所以我只能回答正确的问题.

biakaveron answered my question with a comment so I can't except the correct answer.

从Wouters的官方Kohana论坛(biakaveron指出)上得到答案,这是正确的答案:

Taken from Wouters answer on the official Kohana forums (where biakaveron pointed to), this is the correct answer:

非常简单,$table_columns是 具有大量信息的大型阵列,但是 实际上这些信息很少 用于ORM.

It's very easy, $table_columns is a big array with a lot of info, but actually only very little of this info is used in ORM.

这可以做到:

protected $_table_columns = array(
    'id'            =>  array('type'=>'int'),
    'name'          =>  array('type'=>'string'),
    'allowNull'     =>  array('type'=>'string','null'=>TRUE),
    'created'       =>  array('type'=>'int')
);

这篇关于帮助Kohana 3 ORM加快一点速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆