[nautilus/sam/tracker-3: 5/8] Use STRSTARTS in preference to tracker:uri-is-descendant() function




commit b4b859b7c056ce91071afb93cd3a7111e0715e13
Author: Sam Thursfield <sam afuera me uk>
Date:   Tue Aug 18 22:09:16 2020 +0200

    Use STRSTARTS in preference to tracker:uri-is-descendant() function
    
    In current versions of Tracker, using STRSTARTS to compare URIs is
    faster than using Tracker's custom tracker:uri-is-descendant() function.
    The former allows SQLite to use an index while the latter does not.

 src/nautilus-search-engine-tracker.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c
index 82876368a..cff28eb71 100644
--- a/src/nautilus-search-engine-tracker.c
+++ b/src/nautilus-search-engine-tracker.c
@@ -384,7 +384,10 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider)
     }
     else
     {
-        g_string_append_printf (sparql, "tracker:uri-is-descendant('%s', ?url)", location_uri);
+        /* STRSTARTS is faster than tracker:uri-is-descendant().
+         * See https://gitlab.gnome.org/GNOME/tracker/-/issues/243
+         */
+        g_string_append_printf (sparql, "STRSTARTS(?url, '%s/')", location_uri);
     }
 
     date_range = nautilus_query_get_date_range (tracker->query);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]