summaryrefslogtreecommitdiff
path: root/docs/reference/libtracker-sparql/performance.md
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2023-02-25 18:25:21 +0100
committerCarlos Garnacho <carlosg@gnome.org>2023-02-27 09:18:57 +0100
commitd5afe4a0878162d51980a672aa0d9730f45640ab (patch)
tree64692a62722cd86fc7d9433d0891a1cd86b3ebfd /docs/reference/libtracker-sparql/performance.md
parentf76af4e5c00b8edb041e70d01320c9a363dd4b3b (diff)
downloadtracker-d5afe4a0878162d51980a672aa0d9730f45640ab.tar.gz
docs: Update additional reference documentation
Update it to the gi-docgen syntax, fix links, flesh out docs some more, and make documents generally make a better use of the navigation sidebar. The several subsections describing ontologies have been merge into a single document.
Diffstat (limited to 'docs/reference/libtracker-sparql/performance.md')
-rw-r--r--docs/reference/libtracker-sparql/performance.md27
1 files changed, 12 insertions, 15 deletions
diff --git a/docs/reference/libtracker-sparql/performance.md b/docs/reference/libtracker-sparql/performance.md
index 3994d850f..942b2de57 100644
--- a/docs/reference/libtracker-sparql/performance.md
+++ b/docs/reference/libtracker-sparql/performance.md
@@ -1,13 +1,9 @@
----
-title: Performance dos and donts
-short-description: Performance dos and donts
-...
-
-# Performance advise
+Title: Performance dos and donts
+slug: performance-advise
SPARQL is a very powerful query language. As it should be
suspected, this means there are areas where performance is
-sacrificed for versatility.
+inherently sacrificed for versatility.
These are some tips to get the best of SPARQL as implemented
by Tracker.
@@ -20,7 +16,7 @@ Queries with unrestricted predicates are those like:
SELECT ?p { <a> ?p 42 }
```
-They involve lookups across all possible triples of
+These involve lookups across all possible triples of
an object, which roughly translates to a traversal
through all tables and columns.
@@ -30,7 +26,8 @@ The most pathological case is:
SELECT ?s ?p ?o { ?s ?p ?o }
```
-Which does retrieve every triple existing in the store.
+Which does retrieve every triple existing in the RDF
+triple store.
Queries with unrestricted predicates are most useful to
introspect resources, or the triple store in its entirety.
@@ -76,11 +73,11 @@ The graph(s) may be specified through
SPARQL syntax for graphs. For example:
```SPARQL
-WITH <G> SELECT ?u { ?u a rdfs:Resource }
-WITH <G> SELECT ?g ?u { GRAPH ?g { ?u a rdfs:Resource }}
+WITH <http://example.com/Graph> SELECT ?u { ?u a rdfs:Resource }
+SELECT ?g ?u FROM NAMED <http://example.com/Graph> { GRAPH ?g { ?u a rdfs:Resource }}
```
-## Avoid substring matching
+## Avoid globs and substring matching
Matching for regexp/glob/substrings defeats any index text fields
could have. For example:
@@ -88,7 +85,7 @@ could have. For example:
```SPARQL
SELECT ?u {
?u nie:title ?title .
- FILTER (CONTAINS (?title, "sideshow"))
+ FILTER (CONTAINS (?title, "banana"))
}
```
@@ -97,11 +94,11 @@ encouraged to use fulltext search for finding matches within strings
where possible, for example:
```SPARQL
-SELECT ?u { ?u fts:match "sideshow" }
+SELECT ?u { ?u fts:match "banana" }
```
## Use TrackerSparqlStatement
-Using [](TrackerSparqlStatement) allows to parse and compile
+Using [class@Tracker.SparqlStatement] allows to parse and compile
a query once, and reuse it many times. Its usage
is recommended wherever possible.