I'm using GraphDB-SE 6.4.4 and the triple store is spatially indexed, I followed the steps here:http://owlim.ontotext.com/display/GraphDB6/GraphDB-SE+Geo-spatial+Extensions

When I'm using this query, called Q1:

PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
select ?a ?lat ?long 
WHERE {
    ?a omgeo:within(22.92 -142.38 75.23 183.69) . 
    ?a geo-pos:lat ?lat . 
    ?a geo-pos:long ?long .

} limit 5000

It only takes less than a second, omgeo:within(22.92 -142.38 75.23 183.69) is using the spatial index of the triple store.

Also, when I use this query, called Q2:

PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
select ?a ?lat ?long 
WHERE {
    ?a a ?o .
    filter(?o = someclass) .
    ?a geo-pos:long ?long .

} limit 5000

or this query, called Q3:

PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
select ?a ?lat ?long 
WHERE {
    ?a a someclass .    
    ?a geo-pos:lat ?lat . 
    ?a geo-pos:long ?long .
} limit 5000

They return the same results and both take about 1 second.

But if I use this query, called Q4:

PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> 
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
select ?a ?lat ?long 
WHERE {
    ?a omgeo:within(22.92 -142.38 75.23 183.69) . 
    ?a a ?o .
    filter(?o = someclass) .
    ?a geo-pos:lat ?lat . 
    ?a geo-pos:long ?long .

} limit 5000

It takes more than 60 seconds. Do you know why this happens? Even if Q2 and Q3 returns 0 result, which means that the someclass I queried about has no instance, Q4 still takes more than 60 seconds. Is there a more efficient way to write Q4?

asked 08 Oct '15, 03:21

al3xtouch's gravatar image

al3xtouch
469813
accept rate: 0%


Hi,

We suspect that there might be some issue with our query optimization engine, to be able to further investigate, can you post the query explain plan for Q4 here.

To retrieve an explain plan you should add a prefix: onto: http://www.ontotext.com/, and change the query by adding:

select ?a ?lat ?long from onto:explain WHERE { ...

link

answered 20 Oct '15, 06:21

Venelin%20Kotsev's gravatar image

Venelin Kotsev
4212
accept rate: 20%

the explain plan is in the screenshot, Q1, Q2 and Q3 all only took like 1 or 2 seconds.

(20 Oct '15, 17:36) al3xtouch

The screenshot of the explain plan:

http://prntscr.com/8thlzj

link

answered 20 Oct '15, 17:43

al3xtouch's gravatar image

al3xtouch
469813
accept rate: 0%

IMHO, the problem is that all queries that make use of spatial data become fragile. Some combinations will still work after playing around with nested queries and filters, but these will also fall apart if the query becomes a tiny bit more complex.

To give one very small example:

select ?place WHERE {

 ?place <http://example.com#hasPrimaryName> ?o .
FILTER (contains(?o,'Paris'))

} limit 5000

Takes less than 2 seconds.

select ?place WHERE { ?place omgeo:within(22.92 -142.38 75.23 183.69) .

} limit 5000

Takes about 1 second.

Combining both takes 35 seconds:

select ?place WHERE { ?place omgeo:within(22.92 -142.38 75.23 183.69) . ?place http://example.com#hasPrimaryName ?o . FILTER (contains(?o,'Paris'))

} limit 5000

link

answered 20 Oct '15, 19:18

kjano's gravatar image

kjano
1
accept rate: 0%

Dear Venelin, are there any updates or suggestions how we can handle the current situation?

link

answered 25 Oct '15, 22:38

kjano's gravatar image

kjano
1
accept rate: 0%

We would recommend to use GraphDB's GeoSparql support, introduced in GraphDB 6.5

link

answered 13 Nov '15, 11:12

Venelin%20Kotsev's gravatar image

Venelin Kotsev
4212
accept rate: 20%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×37
×12
×11
×5

Asked: 08 Oct '15, 03:21

Seen: 2,554 times

Last updated: 23 May, 00:56

powered by BitNami OSQA