Search code examples
sparqljenafuseki

Will SPARQL graphs maintain order after updates?


I have some items in a graph I need to retrieve with SPARQL and process individually. I want to get each item using OFFSET and LIMIT, like

SELECT *
WHERE
{ ?s ?p ?o }
OFFSET 23
LIMIT 1

It seems the Jena Fuseki server maintains item order when there are no updates, so that the next item at OFFSET 24 will always be the same. Is that an unfounded assumption? Will the ordering be the same after an update?


Solution

  • Nothing is guaranteed. The fact it happens to return the same order each time is not part of the formal API.

    After an update, it may well change. It depends on the storage implementation you are using.

    Result sets are sent back in a streaming fashion - the client can read some results, do soemthing then read some more, if the client is unable to receive the whole results at once.

    Use ORDER BY to get a fixed order.