On Thursday 10 May 2012 13:03:17 Krzysztof Sielski wrote: > Hello, > > I noticed a very poor performance for evaluating some queries, > particularly those using geo-spatial extension plugin. I use geospatial > index to find all places located near to a given point and the query > result (about 1000 uris) is returned immediately: > > (q1) PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> > select * WHERE { > ?place omgeo:nearby("52.574472150718606" "17.008895874023438" "100") > . } > > However, when I want to get also places' names (every place has exacly > one name, so the result contains the same tuple count as above) - the > query takes about 3 minutes to finish: > > (q2) PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> > PREFIX cidoc: <http://erlangen-crm.org/current/> > select * WHERE { > ?place omgeo:nearby("52.574472150718606" "17.008895874023438" "100") > . ?place cidoc:P1_is_identified_by ?appellation > } > > Finally, I noticed that a modification (putting the latter triple > template into an optional clause) solves the problem, i.e. it returns > the same tuples as above query and executes very fast: > > (q3) PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> > PREFIX cidoc: <http://erlangen-crm.org/current/> > select * WHERE { > ?place omgeo:nearby("52.574472150718606" "17.008895874023438" "100") > . optional { ?place cidoc:P1_is_identified_by ?appellation } > } > > Why the second query executes so long? I thought that it might be an > issue with the query optimizer, but when I turned it off > (-Denable-optimization=false) the queries did not return any result at all! > > My repository has over 500.000.000 triples and runs on Owlim SE 4.3.4423.
Hi Krzysztof, I'm sorry to hear you're having trouble. About disabling query optimisation - currently disabling optimisation also disables the use of all advanced features (geo-spatial index, lucene index, etc.). It seems you're hitting an edge-case of the query optimiser where its estimate prefers to execute the geo-spatial constraint last, rather than first. I imagine it might happen if you have a lot of alternative names per place, but I can't really guess why exactly it's happening. For your case I'd recommend using optional like in (q3), plus "FILTER BOUND(?place)", i.e. (q3') PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> PREFIX cidoc: <http://erlangen-crm.org/current/> select * WHERE { ?place omgeo:nearby("52.574472150718606" "17.008895874023438" "100"). optional { ?place cidoc:P1_is_identified_by ?appellation } filter bound(?place). } This won't work well if most places are unnamed, though. Hope this helps. -- Dimitar Toshev _______________________________________________ Owlim-discussion mailing list [email protected] http://ontomail.semdata.org/cgi-bin/mailman/listinfo/owlim-discussion
