问题
I'm trying to get something done, but I got performance issues.
I got stores, and products. The products are linked to the stores via :inStore predicate. The main purpose here is to get 5 products from each matched store with total limit of 75 products. The order should be the closest ?distance and the highest ?price. Here's my query:
SELECT ?store ?productID ?distance ?price {
{
SELECT ?store ?distance {
?store omgeo:nearby(51.5125591000 -0.1248754000 '100km') .
?store geo-pos:lat ?latBase .
?store geo-pos:long ?longBase .
BIND (omgeo:distance(51.5125591000, -0.1248754000, ?latBase, ?longBase) AS ?distance)
} ORDER BY (?distance)
}
OPTIONAL {
{
SELECT ?productID ?price {
{
SELECT ?productID {
?productID :inStore ?store .
}
}
?productID :price ?price .
} ORDER BY DESC(?price) LIMIT 5
}
}
FILTER (BOUND(?productID))
} LIMIT 75
The problem here is that this is extremly slow on a very powerful server. Any suggestions?
来源:https://stackoverflow.com/questions/29469353/selecting-limited-subquery-data-with-sparql-1-1