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
DBIx::Class::QueryLog(3) User Contributed Perl Documentation DBIx::Class::QueryLog(3)

DBIx::Class::QueryLog - Log queries for later analysis.

version 1.005001

DBIx::Class::QueryLog 'logs' each transaction and query executed so you can analyze what happened in the 'session'. It must be installed as the debugobj in DBIx::Class:

    use DBIx::Class::QueryLog::NotifyOnMax;
    use DBIx::Class::QueryLog::Analyzer;

    my $schema = ... # Get your schema!
    my $ql = DBIx::Class::QueryLog::NotifyOnMax->new(
        max_count => 100,
    );
    $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;

Every transaction and query executed will have a corresponding Transaction and Query object stored in order of execution, like so:

    Query
    Query
    Transaction
    Query

This array can be retrieved with the log method. Queries executed inside a transaction are stored inside their Transaction object, not inside the QueryLog directly.

See DBIx::Class::QueryLog::Analyzer for options on digesting the results of a QueryLog session.

If you wish to have the QueryLog collecting results, and the normal trace output of SQL queries from DBIx::Class, then set "passthrough" to 1

  $ql->passthrough(1);

Note that above the example uses DBIx::Class::QueryLog::NotifyOnMax instead of the vanilla "DBIx::Class::QueryLog", this is simply to encourage users to use that and hopefully avoid leaks.

Sometimes you want to break your analysis down into stages. To segregate the queries and transactions, simply set the bucket and run some queries:

  $ql->bucket('selects');
  $schema->resultset('Foo')->find(..);
  # Some queries
  $ql->bucket('updates');
  $foo->update({ name => 'Gorch' });
  $ql->bucket('something else);
  ...

Any time a query or transaction is completed the QueryLog's current bucket will be copied into it so that the Analyzer can later use it. See the get_totaled_queries method and it's optional parameter.

Create a new DBIx::Class::QueryLog.

Set the current bucket for this QueryLog. This bucket will be copied to any transactions or queries that finish.

Returns the total time elapsed for ALL transactions and queries in this log.

Returns the number of queries executed in this QueryLog

Reset this QueryLog by removing all transcations and queries.

Add this provided Transaction or Query to the log.

Called by DBIx::Class when a transaction is begun.

Called by DBIx::Class when a transaction is committed.

Called by DBIx::Class when a transaction is rolled back.

Called by DBIx::Class when a query is begun.

Called by DBIx::Class when a query is completed.

Returns the name of the class to use for storing queries, by default "DBIx::Class::QueryLog::Query". If you subclass "DBIx::Class::QueryLog", you may wish to override this. Whatever you override it to must be a subclass of DBIx::Class::QueryLog::Query.

As query_class but for the class for storing transactions. Defaults to "DBIx::Class::QueryLog::Transaction".

  • DBIx::Class::QueryLog::NotifyOnMax
  • DBIx::Class::QueryLog::Tee
  • DBIx::Class::QueryLog::Conditional

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

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.

2015-12-08 perl v5.32.1

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

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