LP#1738488 Optimize Flattener join logic
authorDan Wells <dbw2@calvin.edu>
Fri, 2 Mar 2018 17:54:46 +0000 (12:54 -0500)
committerJason Stephenson <jason@sigio.com>
Tue, 3 Apr 2018 19:19:55 +0000 (15:19 -0400)
commit71d6594ce721b1d12908c5366bf28e555b2d3145
treea70c219c3f4592a183743889fda69156ea5ed8ae
parentedae2423cc5f20fdd3cdcf05cae8a3b04ff268a3
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>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Flattener.pm