https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42585

--- Comment #13 from Kyle M Hall (khall) <[email protected]> ---
Created attachment 207236
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207236&action=edit
Bug 42585: Add analyzer infrastructure

Librarians write saved SQL reports that pull all of items, sort the
whole borrowers table, or buffer millions of rows into the Plack
worker. There's no warning. They click Run, the database or the app
server falls over, and the report never finishes.

This patch adds the runner, the analysis context, the check base
class and the registry every check will hang off, along with the
placeholder, EXPLAIN and server statistics helpers. No checks are
registered yet, they come in the following patches.

A check can mark its findings scale dependent, meaning they only
matter once there's enough data behind them. The runner asks EXPLAIN
how many rows the query expects to examine and sets those findings
aside when the answer is small. That estimate already accounts for
the WHERE clause, and for a trailing LIMIT when the plan can stream
rows straight out, so "SELECT * FROM items LIMIT 10" doesn't get
warned about while "SELECT * FROM items ORDER BY RAND() LIMIT 1"
still does, because the sort reads every row before the LIMIT
applies.

A finding set aside this way is still returned, marked suppressed and
carrying the reason, so a librarian on a small database can tell the
difference between the analyzer noticing nothing and the analyzer
noticing nothing that matters here.

Test Plan:
1) Apply this patch
2) prove -r t/Koha/Reports/Analyzer/ t/db_dependent/Koha/Reports/
3) In a koha-shell, run:
   perl -MKoha::Reports::Analyzer=analyze -MData::Dumper -e \
     'print Dumper analyze({ sql => "SELECT 1" })'
4) Note the empty findings list, the runner works but no checks are
   registered yet!
5) Repeat with "SELECT * FROM borrowers LIMIT 5", note estimated_rows
   is 5 rather than the number of rows in the table!
6) Repeat with "SELECT * FROM borrowers ORDER BY RAND() LIMIT 5", note
   estimated_rows is the whole table again because the sort has to
   read every row before the LIMIT applies!

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to