I tried both queries, with union Graph , and without , and the result is
interesting and not ambiguous ( measured with time wget ) :

   - with union Graph : around 0.07 second
   - without union Graph:  12 seconds


About the inheritance depth, the main use case currently is to get the
foaf:Person when asking for a foaf:Agent .

Then other cases are the dbPedia stuff like cites, places .

And taxonomic data about species where family, genus, species are modeled
by RDF classes, and the depth (8) is like this

Kingdom: Plantae <https://en.wikipedia.org/wiki/Plant>
(unranked): Angiosperms <https://en.wikipedia.org/wiki/Angiosperms>
(unranked): Eudicots <https://en.wikipedia.org/wiki/Eudicots>
(unranked): Asterids <https://en.wikipedia.org/wiki/Asterids>
Order: Lamiales <https://en.wikipedia.org/wiki/Lamiales>
Family: Lamiaceae <https://en.wikipedia.org/wiki/Lamiaceae>
Genus: *Salvia <https://en.wikipedia.org/wiki/Salvia>*
Species: *S. fruticosa*

I would say, generally no deep hierarchy.


Here is there the query with union Graph :

PREFIX text: <http://jena.apache.org/text#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX form: <
http://raw.githubusercontent.com/jmvanel/semantic_forms/master/vocabulary/forms.owl.ttl#
>
SELECT DISTINCT ?thing ?COUNT WHERE {
  ?thing text:query ( 'Jean*' ) .
  GRAPH <urn:x-arq:UnionGraph> {
    ?thing a ?sub .
    ?sub rdfs:subClassOf* <http://xmlns.com/foaf/0.1/Person> .
  OPTIONAL {
     ?thing form:linksCount ?COUNT.
   }
}
}
ORDER BY DESC(?COUNT)

LIMIT 10


and the one originally posted, more complex, and less efficient ( but same
result):

PREFIX text: <http://jena.apache.org/text#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX form: <
http://raw.githubusercontent.com/jmvanel/semantic_forms/master/vocabulary/forms.owl.ttl#
>
SELECT DISTINCT ?thing ?COUNT WHERE {
  ?thing text:query ( 'Jean*' ) .
  graph ?g1 {
    ?thing a ?sub .
  }
  graph ?g2 {
    ?sub rdfs:subClassOf* <http://xmlns.com/foaf/0.1/Person> .
  } .
  OPTIONAL {
    graph ?grCount {
     ?thing form:linksCount ?COUNT.
   } }
}
ORDER BY DESC(?COUNT)
LIMIT 10

2018-02-08 16:19 GMT+01:00 Andy Seaborne <a...@apache.org>:

>
>
> On 08/02/18 08:39, Jean-Marc Vanel wrote:
>
>> Hi
>>
>> I wonder about performance of  arbitrary length path in Jena :
>> https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#prop
>> ertypath-arbitrary-length
>>
>> For example , here is the query in semantic_forms for searching a string
>> with a type class. I added yesterday the rdfs:subClassOf* pattern.
>> I wonder if it would not be more efficient with the unionGraph instead of
>> numerous GRAPH blocks .
>>
>
> if you try it, please do report on the effect.
>
> GRAPH <urn:x-arq:UnionGraph>
>
> Are the rdfs:subClassOf hierarchies very deep?
>
> As you have it, there is a bit of cross product of ?g1 and ?g2 going on.
>
>     Andy
>
>
>> PREFIX text: <http://jena.apache.org/text#>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>> PREFIX form: <
>> http://raw.githubusercontent.com/jmvanel/semantic_forms/mast
>> er/vocabulary/forms.owl.ttl#
>>
>>>
>>>
>> SELECT DISTINCT ?thing ?COUNT WHERE {
>>   ?thing text:query ( 'Jean*' ) .
>>
>>   graph ?g1 {
>>     ?thing a ?sub .
>>   }
>>   graph ?g2 {
>>     ?sub *rdfs:subClassOf** <http://xmlns.com/foaf/0.1/Person> .
>>   } .
>>   OPTIONAL {
>>     graph ?grCount {
>>      ?thing form:linksCount ?COUNT.
>>    } }
>> }
>> ORDER BY DESC(?COUNT)
>> LIMIT 10
>>
>>
>>


-- 
Jean-Marc Vanel
http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject
<http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me>
Déductions SARL - Consulting, services, training,
Rule-based programming, Semantic Web
+33 (0)6 89 16 29 52
Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui

Reply via email to