kohana-3kohana-orm

Helping Kohana 3 ORM to speed up a little


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?


Solution

  • 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:

    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.

    This will do:

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