SPARQL Query Optimization

Hi All,

I am very new in using sparql. I have the below query that I'm currently looking for ways to optimize. Currently here is the execution metrics:

Query mode | query
Request execution time (ms) | 24316.423
Status code | 200
Status OK? | True
# of results | 5
Response content size (bytes) | 5622

I will love to see this execution significantly.

PREFIX rdfs: <> 
PREFIX sck: <>
            ?resourceUri a sck:Resource ;
            rdfs:label ?resourceName .
            ?resourceFactorUri sck:converts ?resourceUri ;
            sck:dateFrom ?dateFrom ;
            sck:dateTo ?dateTo ;
            sck:hasAssetOwner/rdfs:label ?owner ;
            sck:hasSource/rdfs:label ?source;
            sck:hasLocation/rdfs:label ?location.
            FILTER CONTAINS(LCASE(?resourceName), LCASE("")) .
            FILTER CONTAINS(LCASE(?owner), LCASE("")) .
            FILTER CONTAINS(LCASE(?location), LCASE("")) .
            FILTER CONTAINS(LCASE(?source), LCASE("")) .
            FILTER (CONTAINS(LCASE(?resourceName), LCASE("steel")) ||  CONTAINS(LCASE(?owner), LCASE("steel")) || CONTAINS(LCASE(?location), LCASE("steel")) || CONTAINS(LCASE(?source), LCASE("steel"))).
            FILTER(STR(?resourceFactorUri) > "")
ORDER BY ?resourceFactorUri

Any help or suggestions will be greatly appreciated.

Can you include the query plan by running Stardog query explain <my-query> and send the results?

Thanks for the help.

My pleasure. Can you include the text. I can't read what you provided.

It looks like it's the scaled down version that's unreadable but the full size image is ok.....but still the text would be nice.

Adding the --profile option to the explain command would tell where the query spends most of the execution time. The image you attached doesn't seem to be generated by Stardog. We definitely don't have stuff like ConditionalRouting or TermResolution.

If I had to guess, this query is unlikely to perform very well on large datasets because your most selective condition uses string functions (contains and lcase). You may have better luck enabling the full-text search index: Full-text Search | Stardog Documentation Latest