GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBIX::CLASS::QUERYLOG::ANALYZER (3)

.ds Aq ’

NAME

DBIx::Class::QueryLog::Analyzer - Query Analysis

CONTENTS

VERSION

version 1.005001

SYNOPSIS

Analyzes the results of a QueryLog. Create an Analyzer and pass it the QueryLog:



    my $schema = ... # Get your schema!
    my $ql = DBIx::Class::QueryLog->new;
    $schema->storage->debugobj($ql);
    $schema->storage->debug(1);
    ... # do some stuff!
    my $ana = DBIx::Class::QueryLog::Analyzer->new({ querylog => $ql });
    my @queries = $ana->get_sorted_queries;
    # or...
    my $totaled = $ana->get_totaled_queries;



METHODS

    new

Create a new DBIx::Class::QueryLog::Analyzer

    get_sorted_queries

Returns an arrayref of all Query objects, sorted by elapsed time (descending).

    get_fastest_query_executions($sql_statement)

Returns an arrayref of Query objects representing in order of the fastest executions of a given statement. Accepts either SQL or a DBIx::Class::QueryLog::Query object. If given SQL, it must match the executed SQL, including placeholders.



  $ana->get_slowest_query_executions("SELECT foo FROM bar WHERE gorch = ?");



    get_slowest_query_executions($sql_statement)

Opposite of get_fastest_query_executions. Same arguments.

    get_totaled_queries

Returns hashref of the queries executed, with same-SQL combined and totaled. So if the same query is executed multiple times, it will be combined into a single entry. The structure is:



    $var = {
        SQL that was EXECUTED => {
            count           => 2,
            time_elapsed    => 1931,
            queries         => [
                DBIx::Class::QueryLog...,
                DBIx::Class::QueryLog...
            ]
        }
    }



This is useful for when you’ve fine-tuned individually slow queries and need to isolate which queries are executed a lot, so that you can determine which to focus on next.

To sort it you’ll want to use something like this (sorry for the long line, blame perl...):



    my $analyzed = $ana->get_totaled_queries;
    my @keys = reverse sort {
            $analyzed->{$a}->{time_elapsed} <=> $analyzed->{$b}->{time_elapsed}
        } keys(%{ $analyzed });



So one could sort by count or time_elapsed.

    get_totaled_queries_by_bucket

Same as get_totaled_queries, but breaks the totaled queries up by bucket:

$var = {
’bucket1’ => {
SQL that was EXECUTED’ => {
count => 2,
time_elapsed => 1931,
queries => [
DBIx::Class::QueryLog...,
DBIx::Class::QueryLog...
]
}
}
’bucket2’ => { ... } }

It is otherwise identical to get_totaled_queries

AUTHORS

o Arthur Axel fREW Schmidt <frioux+cpan@gmail.com>
o Cory G Watson <gphat at cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Cory G Watson <gphat at cpan.org>.

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

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBIX::CLASS::QUERYLOG::ANALYZER (3) 2015-12-08

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.