Nyamiou The Galeanthrope
Nyamiou The Galeanthrope

Reputation: 1214

SPARQL optional not bound VS filter not exists

Is there a difference (in term of performances, respects of standards or anything else) between:

select distinct ?planeWithoutPassengers where {
    ?planeWithoutPassengers a <http://example.org/plane> .
    filter not exists {
        ?planeWithoutPassengers <http://example.org/hasPassenger> ?passenger .
    }
}

And:

select distinct ?planeWithoutPassengers where {
    ?planeWithoutPassengers a <http://example.org/plane> .
    optional {
        ?planeWithoutPassengers <http://example.org/hasPassenger> ?passenger .
    }
    filter (!bound(?passenger)).
}

Upvotes: 2

Views: 1746

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22052

There is no real difference. The second one is the older version which also works on SPARQL 1.0 engines. However the first one is preferred as it reads more intuitively.

Upvotes: 3

Related Questions