Query
SELECT ?president
WHERE {
:Washington :successor+ ?president .
?president :diedInOffice true .
}
UNTIL (?president :diedInOffice true)
WHERE {
:Washington :successor+ ?president .
?president :diedInOffice true .
}
UNTIL (?president :diedInOffice true)
Without UNTIL
Standard SPARQL traverses every reachable node via
:successor+, collecting all of them, then filters for :diedInOffice true as a post-filter. On a chain of 46 presidents, this means 46 hops even if the answer is at hop 9.
With UNTIL
The UNTIL clause evaluates the exit predicate at each step during traversal. The moment
:diedInOffice true is found, that branch terminates immediately. The remaining nodes are never visited. This is per-step predicate evaluation, not post-filtering.
Steps