Pg::Explain::Buffers - Object to store buffers information about node in PostgreSQL's explain analyze
Version 1.13
Quick summary of what the module does.
Perhaps a little code snippet.
use Pg::Explain; my $explain = Pg::Explain->new('source_file' => 'some_file.out'); ... if ( $explain->top_node->buffers ) { print $explain->top_node->buffers->as_text(); } ...
Alternatively you can build the object itself from either a string (conforming to text version of EXPLAIN ANALYZE output) or a structure, containing keys like in JSON/YAML/XML formats of the explain:
use Pg::Explain::Buffers; my $from_string = Pg::Explain::Buffers->new( 'Buffers: shared hit=12101 read=73' ); my $from_struct = Pg::Explain::Buffers->new( { 'Shared Hit Blocks' => 12101, 'Shared Read Blocks' => 73, } );
To such object you can later on add Timing information, though only with string - if you had it in struct, make it available on creation.
$buffers->add_timing( 'I/O Timings: read=58.316 write=1.672' );
Object constructor.
Takes one argument, either a string or hashref to build data from.
Adds timing information to existing buffer info.
Returns text representation of stored buffers info, together with timings (if available).
Returns hash(ref) with all data about buffers from this object. Keys in this hash:
shared (with subkeys: hit, read, dirtied, written)
local (with subkeys: hit, read, dirtied, written)
temp (with subkeys: read, written)
timings (with subkeys: read, write
Only elements with non-zero values are returned. If there are no elements to be returned, it returns undef.
Accessor to internal data.
To allow for easier work on buffer values + and - operators are overloaded, so you can:
$buffers_out = $buffers1 - $buffers2;
While processing subtraction, it is important that it's not possible to get negative values, so if any value would drop below 0, it will get auto-adjusted to 0.
Gets data out of provided HASH.
Gets data out of provided string.
Creates new Pg::Explain::Buffers object by adding values based on two objects. To be used like:
my $result = $buffers1 + $buffers2;
Creates new Pg::Explain::Buffers object by subtracting values based on two objects. To be used like:
my $result = $buffers1 - $buffers2;
For checking if given variable is set, as in:
$r = $buffers1 - $buffers2; if ( $r ) {...}
hubert depesz lubaczewski, <depesz at depesz.com>
<depesz at depesz.com>
Please report any bugs or feature requests to depesz at depesz.com.
depesz at depesz.com
You can find documentation for this module with the perldoc command.
perldoc Pg::Explain::Buffers
Copyright 2008-2021 hubert depesz lubaczewski, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Pg::Explain, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pg::Explain
CPAN shell
perl -MCPAN -e shell install Pg::Explain
For more information on module installation, please visit the detailed CPAN module installation guide.