Skip to content

Commit

Permalink
Further optimize excluding results in not queries (#125)
Browse files Browse the repository at this point in the history
* Further optimize excluding results in not queries

Usually the number of the parameters that have to be excluded in the not query is much lower than the number of values in the index, so it makes sense to actually try to pop them out from the list

* duration1 appears to be lower after the optimizations
  • Loading branch information
ale-rt committed Oct 30, 2021
1 parent d94e333 commit 0b3725c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -285,7 +285,7 @@ def profileSearch(query, warmup=False, verbose=False):
# search must be roughly faster than default search
if res1 and res2:
self.assertLess(
0.5 * duration2,
0.4 * duration2,
duration1,
(duration2, duration1, query))

Expand Down
7 changes: 6 additions & 1 deletion src/Products/PluginIndexes/unindex.py
Expand Up @@ -504,7 +504,12 @@ def query_index(self, record, resultset=None):
i_not_parm = self._apply_not(not_parm, resultset)
if i_not_parm:
return difference(resultset, i_not_parm)
record.keys = [k for k in index.keys() if k not in not_parm]
record.keys = list(index)
for parm in not_parm:
try:
record.keys.remove(parm)
except ValueError:
pass
else:
# convert query arguments into indexed format
record.keys = list(map(self._convert, record.keys))
Expand Down

0 comments on commit 0b3725c

Please sign in to comment.