diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2023-03-07 20:38:46 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2023-03-07 23:18:46 +0100 |
commit | 64697ea95b847749d0e21dfa16ef43dee2564844 (patch) | |
tree | ac865c4f30ebaec5a1eb6c7c95aa011ed26a2aa8 | |
parent | 5822ba76d0edadec80921cf698e215e25c2cc532 (diff) | |
download | gtk+-64697ea95b847749d0e21dfa16ef43dee2564844.tar.gz |
searchengine: Improve performance for recursive search
As fancy as property paths are, recursive resolution of files
to a location increases the big O complexity enough that it's
not a great option on large homedirs with many indexed files.
Ensure the files are from the right location through a URI
prefix match, which does hits an index. This may dramatically
improve performance on large indexed trees.
Testing this query in an isolated testcase with a total
1434099 indexed files shows that it can run more than 1500 times
per second in this computer (an average of 15200 queries in
several 10 second runs), which presumably is a tad faster than
anyone can type.
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4133
-rw-r--r-- | gtk/gtksearchenginetracker3.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gtk/gtksearchenginetracker3.c b/gtk/gtksearchenginetracker3.c index 25f6576c1f..ab3224d2ac 100644 --- a/gtk/gtksearchenginetracker3.c +++ b/gtk/gtksearchenginetracker3.c @@ -52,7 +52,7 @@ "ORDER BY DESC(fts:rank(?urn)) DESC(?url)" #define SEARCH_QUERY SEARCH_QUERY_BASE("") -#define SEARCH_RECURSIVE_QUERY SEARCH_QUERY_BASE("?urn (nfo:belongsToContainer/nie:isStoredAs)+/nie:url ~location") +#define SEARCH_RECURSIVE_QUERY SEARCH_QUERY_BASE("FILTER (STRSTARTS (?url, CONCAT (~location, '/')))") #define SEARCH_LOCATION_QUERY SEARCH_QUERY_BASE("?urn nfo:belongsToContainer/nie:isStoredAs/nie:url ~location") struct _GtkSearchEngineTracker3 |