|
From: Jim B. <ba...@gm...> - 2017-08-08 02:06:22
|
Hi,
I’ve been experimenting with named subqueries and finding they can provide some major performance improvements. The Blazegraph wiki page on query hints lists “runOnce”, saying "The sub-select should be lifted into a named subquery such that it is evaluated exactly once. See NamedSubquery.”
I thought this would allow me to use named subqueries within a legal SPARQL syntax (easier to construct queries programmatically). However I find that using the query hint is much slower (3.5 seconds) than writing out the named subquery (0.3 seconds). Here is an example with a named subquery:
SELECT DISTINCT ?taxon ?taxon_label ?desc
WITH {
SELECT ?phenotype WHERE {?phenotype rdfs:subClassOf/ps:phenotype_of_some pectoral_fin: . }
} AS %namedSet1
WHERE {
?taxon rdfs:label ?taxon_label .
?state dc:description ?desc .
?taxon ps:exhibits_state ?state .
?state ps:describes_phenotype ?phenotype .
INCLUDE %namedSet1
}
ORDER BY ?taxon_label
LIMIT 50
Here is the “same” query with a regular subquery with the query hint:
SELECT DISTINCT ?taxon ?taxon_label ?desc
WHERE {
?taxon rdfs:label ?taxon_label .
?state dc:description ?desc .
?taxon ps:exhibits_state ?state .
?state ps:describes_phenotype ?phenotype .
{
SELECT ?phenotype WHERE {
hint:SubQuery hint:runOnce true .
?phenotype rdfs:subClassOf/ps:phenotype_of_some pectoral_fin: .
}
}
}
ORDER BY ?taxon_label
LIMIT 50
Is the query hint supposed to do the same thing as with the named subquery? The query hint is definitely doing something, because without it, the query never completes in the time I have waited.
Thank you,
Jim
|