Hi everyone,
We've recently run into an issue to do with pagination. In our triple
store we have rows of data represented by 200+ triples (over 200 columns
per row). When the data is queried we take the list of triples and then
pivot it to return it to row data. The information was sourced from a
traditional RDBMS system.
The problem we have is that when queried we need to limit the amount of
data being returned so as not to swamp the servers on every request.
However a LIMIT/OFFSET combination returns only a subset of a rows data (eg
LIMIT 50 returns 50 attributes of the 200 attribute row).
To solve this problem we have embedded a sub query that uses LIMIT/OFFSET
but only operates over the primary key for each row. Then using the
primary key which fetch the rest of the data.
Eg:
SELECT ?pid ?p ?o ?dataset
FROM <graph_A>
FROM <graph_B>
WHERE
{
?pid ?p ?o
{SELECT * WHERE { ?s attribute:primary_key ?pid} LIMIT 20 OFFSET 10}
graph ?dataset { ?s attribute:primary_key ?pid}
}
ORDER BY ?pid
The original query uses the graph ?dataset to provide links to the source
data when viewed through our reporting tools.
The sub-select was added to enabled the limit/offset. It appears that the
sub-select cannot be embedded into the graph ?dataset.
Is anyone aware of a cleaner way of doing this? Are there any potential
issues with sort order - eg the sub-select returned data in a different
order to what is expected? (we don't believe so but it doesn't hurt to ask!)
Many thanks for your input,
Peter Secomb
clearbluewater.com.au