NAME

Catalyst::Plugin::DBIC::QueryLog - Catalyst Plugin for DBIx::Class::QueryLog!

SYNOPSIS

# MyApp.pm
use Catalyst qw/
  ...
  DBIC::QueryLog    # Load this plugin.
  ...
/;

# myapp.yml
DBIC::QueryLog:
  MODEL_NAME: DBIC

USAGE

then in templates:

[% IF c.querylog %]
  <div class="featurebox">
    <h3>Query Log Report</h3>
    [% SET total = c.querylog.time_elapsed | format('%0.6f') %]
    <div>Total SQL Time: [% total | format('%0.6f') %] seconds</div>
    [% SET qcount = c.querylog.count %]
    <div>Total Queries: [% qcount %]</div>
    [% IF qcount %]
    <div>Avg Statement Time: [% (c.querylog.time_elapsed / qcount) | format('%0.6f') %] seconds.</div>
    <div>
     <table class="table1">
      <thead>
       <tr>
        <th colspan="3">5 Slowest Queries</th>
       </tr>
      </thead>
      <tbody>
       <tr>
        <th>Time</th>
        <th>%</th>
        <th>SQL</th>
       </tr>
       [% SET i = 0 %]
       [% FOREACH q = c.querylog_analyzer.get_sorted_queries %]
       <tr class="[% IF loop.count % 2 %]odd[% END %]">
        <th class="sub">[% q.time_elapsed | format('%0.6f') %]
        <td>[% ((q.time_elapsed / total ) * 100 ) | format('%i') %]%</td>
        <td>[% q.sql %]</td>
       </th></tr>
       [% IF i == 5 %]
        [% LAST %]
       [% END %]
       [% SET i = i + 1 %]
       [% END %]
      </tbody>
     </table>
    </div>
    [% END %]
  </div>
[% END %]

SEE ALSO

DBIx::Class::QueryLog

http://www.onemogin.com/blog/554-profile-your-catalystdbixclass-app-with-querylog.html

KNOWN ISSUE

This module is not working well alone with Catalyst::Plugin::DBIC::Schema::Profiler since they are using the same ->storage->debugobj.

AUTHOR

Fayland Lam, <fayland at gmail>

COPYRIGHT & LICENSE

Copyright 2007 Fayland Lam, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.