DBIx::...Explain(3pm)

πŸ“¦
version 2.037000 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– DBIx::Class::Helper::ResultSet::Explain β€” bestie edition ✨

okay so this is a page from the User Contributed Perl Documentation and it's all about DBIx::Class::Helper::ResultSet::Explain, which is lowkey one of my faves because it just tells you what your database is actually doing. no cap. 🫢


✨ NAME ✨

DBIx::Class::Helper::ResultSet::Explain β€” Get query plan for a ResultSet πŸŽ€


🌸 SYNOPSIS 🌸

ngl the main character usage of this module is using it without setting it up as a component. like, just call it directly:

use Devel::Dwarn;
Dwarn DBIx::Class::ResultSet::Explain::explain($rs)

but bestie, if you're a component girlie (and honestly? valid), here's the whole vibe:

package MyApp::Schema::ResultSet::Foo;

__PACKAGE__->load_components(qw{Helper::ResultSet::Explain});

...

1;

and then in a script or whatever you've got going on:

use Devel::Dwarn;
Dwarn $rs->explain;

πŸ’… DESCRIPTION πŸ’…

so basically this is just a handy little tool that hands you the query plan for a given ResultSet. that's it. that's the whole thing. ✨

⚠️ heads up bestie: the output is in no way normalized, so just treat it as a debug tool or something. it's giving "vibes only, don't parse me."

the only DB's that are supported are the ones listed below β€” the rest? not invited to the party. πŸ’€

Have fun! 🌈

also, peep "NOTE" in DBIx::Class::Helper::ResultSet for a nice way to apply it to your entire schema. iykyk. πŸ‘‘


πŸ”₯ EXAMPLE OUTPUT FROM SUPPORTED DB's πŸ”₯

πŸ¦‹ SQlite

[
  [
    0,
    "Init",
    0,
    10,
    0,
    undef,
    0,
    undef,
  ],
  [
    1,
    "OpenRead",
    0,
    3,
    0,
    4,
    0,
    undef,
  ],
  [
    2,
    "Rewind",
    0,
    9,
    0,
    undef,
    0,
    undef,
  ],
  [
    3,
    "Rowid",
    0,
    1,
    0,
    undef,
    0,
    undef,
  ],
  [
    4,
    "Column",
    0,
    1,
    2,
    undef,
    0,
    undef,
  ],
  [
    5,
    "Column",
    0,
    2,
    3,
    undef,
    0,
    undef,
  ],
  [
    6,
    "Column",
    0,
    3,
    4,
    undef,
    0,
    undef,
  ],
  [
    7,
    "ResultRow",
    1,
    4,
    0,
    undef,
    0,
    undef,
  ],
  [
    8,
    "Next",
    0,
    3,
    0,
    undef,
    1,
    undef,
  ],
  [
    9,
    "Halt",
    0,
    0,
    0,
    undef,
    0,
    undef,
  ],
  [
    10,
    "Transaction",
    0,
    0,
    17,
    0,
    1,
    undef,
  ],
  [
    11,
    "Goto",
    0,
    1,
    0,
    undef,
    0,
    undef,
  ],
]

🐘 Pg

[
  [
    "Seq Scan on \"Gnarly\" me  (cost=0.00..16.20 rows=620 width=100) (actual time=0.003..0.003 rows=0 loops=1)",
  ],
  [
    "Planning time: 0.102 ms",
  ],
  [
    "Execution time: 0.023 ms",
  ],
]

🐬 mysql

[
  [
    1,
    "SIMPLE",
    "me",
    "ALL",
    undef,
    undef,
    undef,
    undef,
    1,
    100,
    "",
  ],
]

πŸ‘‘ AUTHOR πŸ‘‘

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> β€” an icon, truly. πŸ’–


This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.

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


and that's the whole page bestie!! this one came from perl v5.40.0, dated 2024-11-16, and it's part of the User Contributed Perl Documentation for DBIx::...Explain(3pm). go forth and EXPLAIN ur queries, you've got this πŸ’œβœ¨πŸ¦‹

πŸ“¦ where this page comes from