You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by GitBox <gi...@apache.org> on 2022/11/10 12:47:53 UTC

[GitHub] [jena] LorenzBuehmann commented on issue #1614: Property path handling in query optimizer and timeout handler

LorenzBuehmann commented on issue #1614:
URL: https://github.com/apache/jena/issues/1614#issuecomment-1310230675

   ### Jena version
   ```
   tdb2.tdbquery --version                                                                                           
   Jena:       VERSION: 4.7.0-SNAPSHOT
   Jena:       BUILD_DATE: 2022-11-10T12:32:30Z
   ```
   
   ### Property path query
   ```
   tdb2.tdbquery --loc /data/coypu/tdb2/wikidata --explain "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
   PREFIX wikibase: <http://wikiba.se/ontology#>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   SELECT ?item ?itemLabel WHERE {
     ?item rdfs:label|skos:altLabel ?itemLabel ;                             
            rdf:type wikibase:Property.
     FILTER(CONTAINS(LCASE(?itemLabel), 'border'@en))
   }
   LIMIT 10"
   12:42:50 INFO  exec            :: QUERY
     PREFIX  skos: <http://www.w3.org/2004/02/skos/core#>
     PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
     PREFIX  wikibase: <http://wikiba.se/ontology#>
     
     SELECT  ?item ?itemLabel
     WHERE
       { ?item rdfs:label|skos:altLabel ?itemLabel .
         ?item  rdf:type  wikibase:Property
         FILTER contains(lcase(?itemLabel), "border"@en)
       }
     LIMIT   10
   12:42:50 INFO  exec            :: ALGEBRA
     (slice _ 10
       (project (?item ?itemLabel)
         (sequence
           (filter (contains (lcase ?itemLabel) "border"@en)
             (graph <urn:x-arq:DefaultGraphNode>
               (path ?item (alt <http://www.w3.org/2000/01/rdf-schema#label> <http://www.w3.org/2004/02/skos/core#altLabel>) ?itemLabel)))
           (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://wikiba.se/ontology#Property>)))))
   12:42:50 INFO  exec            :: TDB2
     (slice _ 10
       (project (?item ?itemLabel)
         (sequence
           (filter (contains (lcase ?itemLabel) "border"@en)
             (graph <urn:x-arq:DefaultGraphNode>
               (path ?item (alt <http://www.w3.org/2000/01/rdf-schema#label> <http://www.w3.org/2004/02/skos/core#altLabel>) ?itemLabel)))
           (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://wikiba.se/ontology#Property>)))))
   12:42:50 INFO  exec            :: TDB2
     (path ?item (alt <http://www.w3.org/2000/01/rdf-schema#label> <http://www.w3.org/2004/02/skos/core#altLabel>) ?itemLabel)
   12:42:50 INFO  exec            :: Path :: ?item <http://www.w3.org/2000/01/rdf-schema#label>|<http://www.w3.org/2004/02/skos/core#altLabel> ?itemLabel
   ```
   
   ### Union query
   I guess, `UNION` clauses can't also be optimized, right? For the rewritten query it would be trivial to transform it, but this is also not reordered I guess? For those tiny queries one could indeed optimize and estimate the size of the `UNION` (`|A| + |B|`), but seems to be always a tradeoff  - for bigger BGPs in the `UNION` it's getting more complex.
   ```
   tdb2.tdbquery --loc /data/coypu/tdb2/wikidata --explain "
   PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
   PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
   PREFIX wikibase: <http://wikiba.se/ontology#>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   SELECT ?item ?itemLabel WHERE {
     {?item rdfs:label ?itemLabel } UNION {?item skos:altLabel ?itemLabel;}
     ?item  rdf:type wikibase:Property.
     FILTER(CONTAINS(LCASE(?itemLabel), 'border'@en))
   }
   LIMIT 10"
   12:37:15 INFO  exec            :: QUERY
     PREFIX  skos: <http://www.w3.org/2004/02/skos/core#>
     PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
     PREFIX  wikibase: <http://wikiba.se/ontology#>
     
     SELECT  ?item ?itemLabel
     WHERE
       {   { ?item  rdfs:label  ?itemLabel }
         UNION
           { ?item  skos:altLabel  ?itemLabel }
         ?item  rdf:type  wikibase:Property
         FILTER contains(lcase(?itemLabel), "border"@en)
       }
     LIMIT   10
   12:37:15 INFO  exec            :: ALGEBRA
     (slice _ 10
       (project (?item ?itemLabel)
         (sequence
           (union
             (filter (contains (lcase ?itemLabel) "border"@en)
               (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/2000/01/rdf-schema#label> ?itemLabel)))
             (filter (contains (lcase ?itemLabel) "border"@en)
               (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/2004/02/skos/core#altLabel> ?itemLabel))))
           (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://wikiba.se/ontology#Property>)))))
   12:37:15 INFO  exec            :: TDB2
     (slice _ 10
       (project (?item ?itemLabel)
         (sequence
           (union
             (filter (contains (lcase ?itemLabel) "border"@en)
               (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/2000/01/rdf-schema#label> ?itemLabel)))
             (filter (contains (lcase ?itemLabel) "border"@en)
               (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/2004/02/skos/core#altLabel> ?itemLabel))))
           (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://wikiba.se/ontology#Property>)))))
   12:37:15 INFO  exec            :: TDB2
     (filter (contains (lcase ?itemLabel) "border"@en)
       (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/2000/01/rdf-schema#label> ?itemLabel)))
   12:37:15 INFO  exec            :: Execute ::   ?item rdfs:label ?itemLabel
   12:37:15 INFO  exec            :: TDB2
     (filter (contains (lcase ?itemLabel) "border"@en)
       (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?item <http://www.w3.org/2004/02/skos/core#altLabel> ?itemLabel)))
   12:37:15 INFO  exec            :: Execute ::   ?item <http://www.w3.org/2004/02/skos/core#altLabel> ?itemLabel
   12:37:28 INFO  exec            :: Execute ::   ?item rdf:type <http://wikiba.se/ontology#Property>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org