[tracker-miners/wip/carlosg/info-query] tracker: Use faster query in "tracker3 info"




commit 0c569af986c0038a865793b7fdecc054a427c76b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jun 8 11:45:23 2021 +0200

    tracker: Use faster query in "tracker3 info"
    
    This query does an union of two unrestricted graph patterns,
    can thus take a long time to resolve, e.g.:
    
        $ time tracker3 info ~ >/dev/null
    
        real        0m6,368s
        user        0m0,032s
        sys         0m0,033s
    
    Since we want to look the same data from the given URN and
    it's direct nie:interpretedAs relations, this is neater to
    do with the "optional" property path '?', e.g.:
    
        { <urn> nie:interpretedAs? ?var ... }
    
    that will resolve to the urn itself, and all elements down
    the nie:interpretedAs relation. The expensive unrestricted
    graph pattern bits will be then resolved with all subjects
    already at hand. This makes things sensibly faster:
    
        $ time tracker3 info ~ >/dev/null
    
        real        0m1,651s
        user        0m0,037s
        sys         0m0,033s

 src/tracker/tracker-info.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/src/tracker/tracker-info.c b/src/tracker/tracker-info.c
index 5ea83350c..b37dcebdf 100644
--- a/src/tracker/tracker-info.c
+++ b/src/tracker/tracker-info.c
@@ -472,13 +472,9 @@ info_run (void)
                query = g_strdup_printf ("SELECT DISTINCT ?predicate ?object ?x"
                                         "  ( EXISTS { ?predicate rdfs:range [ rdfs:subClassOf rdfs:Resource 
] } )"
                                         "WHERE {"
-                                        "  { <%s> ?predicate ?object . } "
-                                        "  UNION "
-                                        "  { <%s> nie:interpretedAs ?x . "
-                                        "    ?x ?predicate ?object . "
-                                        "  } "
-                                        "}",
-                                        urn,
+                                        "  <%s> nie:interpretedAs? ?x . "
+                                        "  ?x ?predicate ?object . "
+                                        "} ORDER BY ?x",
                                         urn);
 
                cursor = tracker_sparql_connection_query (connection, query, NULL, &error);


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