Database Profiling with Zend Db Profiler Firebug

I don’t know why I haven’t been using this for ages. But Zend’s DB Profiler is fun. Only to be used in development so you can see what your database is doing and how fast/slow it’s doing it.

Enable it in your application’s config.ini (or .xml)

db.profiler.enabled = true
db.profiler.class   = "Zend_Db_Profiler_Firebug"

And as long as you’re using the DB Factory to create your connection, everything that happens will be automatically profiled and spewed out via Firebug’s awesome logging.  It shows you time spent, number of queries, the queries themselves and parameters used.  It’s awesome.  Why haven’t I been using this before?

You can also enable it directly on your database object if you don’t want it in your config; for example I have block of code that runs only when debugging is enabled (development environment) and as such I might want to enable the profiler there:

       array('enabled' => true, 'class' => "Zend_Db_Profiler_Firebug"));

Yeah, it’s awesome.

Published by Darryl Clarke

random text goes here, i guess