]> git.evergreen-ils.org Git - Evergreen.git/commit
LP#1775958: Rework pullup mechanism to flatten more nested queries
authorMike Rylander <mrylander@gmail.com>
Fri, 12 Oct 2018 18:43:26 +0000 (14:43 -0400)
committerJason Boyer <JBoyer@equinoxOLI.org>
Wed, 17 May 2023 20:28:45 +0000 (16:28 -0400)
commit42b5b9becc3ad9973b390627f5aabbf707594f62
tree8a2341b17990247a6f118ed166030c1697fc72c1
parent8f3f2029cbe3c3a2e1535d69939ce5aaf4cb0711
LP#1775958: Rework pullup mechanism to flatten more nested queries

The bulk of this commit reworks the query tree pullup logic, which is
responsible for simplifying the query tree that is used to generate the
SQL query for search.  In particular, we now do a better job of finding
opportunities to merge adjacent parts of the query that have the same
requested_class (pre-dealiasing) in the face of boolean OR operators,
explicit grouping, and alternating requested_class values.  The result
is fewer joins in the SQL, which should speed up all but the most
trivial searches, and generally help protect the database from mis- or
mal-constructed queries.  We also now use CTEs to separate branches of
the logical search tree into descrete subqueries, which helps reduce
the total core query JOINs, and provides the planner with more options
for join order.

This also does away with the conversion of a negated atom into an
"un-phrase".  Instead, we just detect and handle those directly as atoms
with a prefix, as appropriate.  This allows single negated words to be
used directly in the core tsquery construct, rather than having them
require a separate join and special where clause.

Additionally, this commit handles phrases differently at both the QP and
SQL level, making use of Postgres's phrase support in modern versions
and simplifying how they're handled within the base parse tree
structure.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Signed-off-by: Jason Boyer <JBoyer@equinoxOLI.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm