LP#1738488 Optimize Flattener join logic collab/dbwells/lp1738488_optimize_flattener_joins
authorDan Wells <dbw2@calvin.edu>
Fri, 2 Mar 2018 17:54:46 +0000 (12:54 -0500)
committerDan Wells <dbw2@calvin.edu>
Fri, 2 Mar 2018 17:54:46 +0000 (12:54 -0500)
commit05361d02c1e4e74f137f8ca349e3dc83ec29958d
treefd8183c19169e329b38cbcc3a338087032ecf63a
parent7a78bdfb3c7dcb9717a585cf451f5322dba50127
LP#1738488 Optimize Flattener join logic

The current Flattener.pm autogenerates necessary joins for sorting
and filtering, but in doing so, it gives every intermediate table a
unique alias, even if the path to that table is exactly the same as
another member in the map we are flattening.

Instead, let's reuse joins whenever the path is identical, even for
intermediate tables.  We do so by tracking every path to each core
type, then reusing as much of that join path as we can.  In cases
where we have different paths to the same type, we still necessarily
provide a new unique alias.

This problem was first noticed in the web staff billing history
interface, where the particular stacking of joins resulted (for one
specific library) in 17 joins and 44,575,740,147,225,592,344,870,912
potential rows.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Flattener.pm