On Thu, Nov 20, 2014 at 4:42 AM, Lucas Wagner <
lucas....@webdrone.fr> wrote:
> Hello,
>
> Sorry to bother you again with that but i have another performance problem
> with stardog.
>
> I'm trying to run a count query which contains FILTER NOT EXISTS and MINUS.
> It takes long time and i can't find how to avoid the problem.
>
> here is the complete request :
>
> SELECT (COUNT(?id) AS ?nb)
> WHERE {
> ?id rdf:type wd:P .
> FILTER NOT EXISTS {?id wd:IST ?IST . ?id rdf:type wd:P . } .
> FILTER NOT EXISTS {?id wd:D ?D . ?id rdf:type wd:P . } .
> MINUS {
> SELECT DISTINCT ?id {
> GRAPH ?a {
> ?id rdf:type wd:P .
> ?b rdf:type wd:AR .
> ?b wdAS ?id .
> }
> }
> }
> }
>
>
> I tried to run the query only with one FILTER NOT EXISTS :
>
> SELECT (COUNT(?id) AS ?nb)
> WHERE {
> ?id rdf:type wd:P .
> FILTER NOT EXISTS {?id wd:IST ?IST . ?id rdf:type wd:P . } .
> }
You don't need the rdf:type triple in the FILTER. That triple will
obviously be satisfied since it also exists in the query body. So try
the simpler query:
SELECT (COUNT(?id) AS ?nb)
WHERE {
?id rdf:type wd:P .
FILTER NOT EXISTS {?id wd:IST ?IST } .
}
>
>
> and it's the same problem.
>
> I also tried to substitute a FILTER to the FILTER NOT EXISTS :
>
> SELECT (COUNT(?id) AS ?nb )
> WHERE {
> ?id rdf:type wd:P .
> ?id ?rel ?o .
> FILTER (?rel != wd:IST) .
> }
This query is not equivalent to the previous query. The filter in this
query is useless since ?rel can bind to rdf:type and any resource that
satisfies the type triple will be returned.
Best,
Evren