SPARQL 可选未绑定 VS 过滤器不存在
SPARQL optional not bound VS filter not exists
两者之间是否存在差异(在性能、标准方面或其他方面):
select distinct ?planeWithoutPassengers where {
?planeWithoutPassengers a <http://example.org/plane> .
filter not exists {
?planeWithoutPassengers <http://example.org/hasPassenger> ?passenger .
}
}
并且:
select distinct ?planeWithoutPassengers where {
?planeWithoutPassengers a <http://example.org/plane> .
optional {
?planeWithoutPassengers <http://example.org/hasPassenger> ?passenger .
}
filter (!bound(?passenger)).
}
没有真正的区别。第二个是旧版本,它也适用于 SPARQL 1.0 引擎。不过首选第一个,读起来更直观
两者之间是否存在差异(在性能、标准方面或其他方面):
select distinct ?planeWithoutPassengers where {
?planeWithoutPassengers a <http://example.org/plane> .
filter not exists {
?planeWithoutPassengers <http://example.org/hasPassenger> ?passenger .
}
}
并且:
select distinct ?planeWithoutPassengers where {
?planeWithoutPassengers a <http://example.org/plane> .
optional {
?planeWithoutPassengers <http://example.org/hasPassenger> ?passenger .
}
filter (!bound(?passenger)).
}
没有真正的区别。第二个是旧版本,它也适用于 SPARQL 1.0 引擎。不过首选第一个,读起来更直观