Queries that use OR instead of IN are less efficient and can lead to situations where the query takes a very long time to complete due to row level scanning. We found one instance where they query had been running for over 10 days! This patch makes ids() return a subquery instead of a list of results, and switches the callers to using IN. The database now resolves the set itself and the queries stay a constant size no matter how large the catalog is. This is super efficient because the subquery doesn't even execute as a separate query since biblionumber is the primary key! Test Plan: 1) Apply the unit tests patch 2) prove t/db_dependent/Koha/Database/DataInconsistency.t 3) Note the ids() subtest fails 4) Apply this patch 5) prove t/db_dependent/Koha/Database/DataInconsistency.t 6) Note all tests pass! 7) Run misc/maintenance/search_for_data_inconsistencies.pl 8) Note the output is the same as before the patch 9) Bonus: Re-run it with DBIC_TRACE=1 and note the queries now use IN (SELECT ...) instead of one OR clause per bib! Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk> |
||
|---|---|---|
| .. | ||
| Auditor.pm | ||
| Columns.pm | ||
| Commenter.pm | ||
| DataInconsistency.pm | ||