[Solar-talk] Sql Profiling

Rodrigo Moraes rodrigo.moraes at gmail.com
Mon Feb 5 10:33:33 PST 2007


One of the new features in Solar 0.26 is the possibility to profile
Sql queries. To turn it on, you need to define 'profiling' as true in
the config:

    $config['Solar_Sql']['config']['profiling'] = true;

I found it very useful to find slow queries and start improving them
when performance becomes a problem. This is how I used it:

I started to log the results from the profiling in a table, because it
is easy to sort and navigate. If you are interested to know how your
queries perform, just add this before Solar::stop():

        // Profile?
        $sql = Solar::config('Solar_Sql', 'config');
        if($sql['profiling'] == true) {
            $sql = Solar::registry('sql');
            $model = Solar::factory('Vendor_Model_SqlProfile');
            $model->save($sql->getProfile());
        }

        // Done!
        Solar::stop();

(turn it off after a while. it does a lot of inserts per request :)

It's a very simple, but easy way to find database bottlenecks. If
you're interested to get it running with no effort, get the model and
rename it to your vendor name:

    http://dev.tipos.org/browser/trunk/Tipos/Model/SqlProfile.php

:)
rodrigo
-------------------------------
http://tipos.com.br


More information about the solar-talk mailing list