I've been working a bit more with ORDER BY problems. Part of the problem may be that we do not serialise the triples into a sequence, so strictly, there is no order for the CONSTRUCT query.
Nevertheless, there is a sequence of solutions, and this is used to slice the solutions, but now it seems that the slices aren't ordered. I have one such example, and this is the explain output from it: REPORT VARCHAR _______________________________________________________________________________ { Fork { Precode: 0: $26 "callret" := Call min_bnode_iri_id () 5: $27 "-ns#type" := Call __i2idn (<constant (http://www.w3.org/1999/02/22-rdf-syntax-ns#type)>) 10: $28 "phs#OntoGraph" := Call __i2idn (<constant (http://msone.computas.no/graphs#OntoGraph)>) 15: $29 ".no/graphs" := Call __i2id (<constant (http://msone.computas.no/graphs)>) 20: $30 ".no/graphs/inferred/nfi/agent-classification" := Call __i2id (<constant (http://msone.computas.no/graphs/inferred/nfi/agent-classification)>) 25: $31 ".no/graphs/inferred/classification" := Call __i2id (<constant (http://msone.computas.no/graphs/inferred/classification)>) 30: $32 ".no/graphs/inferred/bildetest/agent-classification" := Call __i2id (<constant (http://msone.computas.no/graphs/inferred/bildetest/agent-classification)>) 35: $33 ".no/graphs/inferred/mo/agent-classification" := Call __i2id (<constant (http://msone.computas.no/graphs/inferred/mo/agent-classification)>) 40: $34 "ema#label" := Call __i2idn (<constant (http://www.w3.org/2000/01/rdf-schema#label)>) 45: $35 ".no/graphs/ontology/mediasone" := Call __i2id (<constant (http://msone.computas.no/graphs/ontology/mediasone)>) 50: $36 "ema#subClassOf" := Call __i2idn (<constant (http://www.w3.org/2000/01/rdf-schema#subClassOf)>) 55: $37 "ogi#Aktoer" := Call __i2idn (<constant (http://www.computas.com/mediasone-ontologi#Aktoer)>) 60: $38 "ema#label" := Call __i2id (<constant (http://www.w3.org/2000/01/rdf-schema#label)>) 65: $39 "callret" := Call vector (<constant (1)>, <constant (0)>, <constant (3)>, $38 "ema#label", <constant (1)>, <constant (1)>) 70: $40 "-ns#type" := Call __i2id (<constant (http://www.w3.org/1999/02/22-rdf-syntax-ns#type)>) 75: $41 "owl#Class" := Call __i2id (<constant (http://www.w3.org/2002/07/owl#Class)>) 80: $42 "callret" := Call vector (<constant (1)>, <constant (0)>, <constant (3)>, $40 "-ns#type", <constant (3)>, $41 "owl#Class") 85: $43 "callret" := Call vector ($39 "callret", $42 "callret") 90: $44 "callret" := Call vector () 95: BReturn 0 Subquery { Subquery { Union { in iterates $53 "in_iter" over ($29 ".no/graphs", $30 ".no/graphs/inferred/nfi/agent-classification", $31 ".no/graphs/inferred/classification", $32 ".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.00069 rows Key RDF_QUAD_OGPS ASC ($56 "s-1-7-t2-c5.S") <col=523 O = $37 "ogi#Aktoer"> , <col=520 G = $53 "in_iter"> , <col=522 P = $36 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$58 "<DB.DBA.RDF_QUAD s-1-7-t2-c5>" spec 5> in iterates $61 "in_iter" over ($29 ".no/graphs", $30 ".no/graphs/inferred/nfi/agent-classification", $31 ".no/graphs/inferred/classification", $32 ".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.001 rows Key RDF_QUAD_OGPS ASC ($64 "s-1-6-t5.S") <col=523 O = $28 "phs#OntoGraph"> , <col=520 G = $61 "in_iter"> , <col=522 P = $27 "-ns#type"> , <col=521 S < $26 "callret"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$66 "<DB.DBA.RDF_QUAD s-1-6-t5>" spec 5> from DB.DBA.RDF_QUAD by RDF_QUAD 0.43 rows Key RDF_QUAD ASC ($70 "s-1-19-t6.O", $69 "s-1-19-t6.S", $68 "s-1-19-t6.G") inlined <col=520 G = $64 "s-1-6-t5.S"> , <col=521 S = $56 "s-1-7-t2-c5.S"> , <col=522 P = $34 "ema#label"> Current of: <$72 "<DB.DBA.RDF_QUAD s-1-19-t6>" spec 5> After test: 0: $73 "callret" := Call one_of_these ($68 "s-1-19-t6.G", $30 ".no/graphs/inferred/nfi/agent-classification", $35 ".no/graphs/ontology/mediasone", $32".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") 5: if (<constant (0)> 2(<) $73 "callret") then 9 else 24 unkn 24 9: $74 "callret" := Call __ro2sq ($70 "s-1-19-t6.O") 14: $75 "callret" := Call rdf_regex_impl ($74 "callret", <constant (KJE)>, <constant (i)>) 19: if (<constant (0)> 1(=) $75 "callret") then 24 else 23 unkn 24 23: BReturn 1 24: BReturn 0 After code: 0: $48 "title" := := artm $70 "s-1-19-t6.O" 4: $49 "class" := := artm $69 "s-1-19-t6.S" 8: BReturn 0 Subquery Select($48 "title", $49 "class", <$72 "<DB.DBA.RDF_QUAD s-1-19-t6>" spec 5>, <$66 "<DB.DBA.RDF_QUAD s-1-6-t5>" spec 5>, <$58 "<DB.DBA.RDF_QUAD s-1-7-t2-c5>" spec 5>) } { in iterates $84 "in_iter" over ($29 ".no/graphs", $30 ".no/graphs/inferred/nfi/agent-classification", $31 ".no/graphs/inferred/classification", $32 ".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.00069 rows Key RDF_QUAD_OGPS ASC ($87 "s-1-11-t3.S") <col=523 O = $37 "ogi#Aktoer"> , <col=520 G = $84 "in_iter"> , <col=522 P = $36 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$89 "<DB.DBA.RDF_QUAD s-1-11-t3>" spec 5> in iterates $92 "in_iter" over ($29 ".no/graphs", $30 ".no/graphs/inferred/nfi/agent-classification", $31 ".no/graphs/inferred/classification", $32 ".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.00069 rows Key RDF_QUAD_OGPS ASC ($95 "s-1-11-t4.S") <col=523 O = $87 "s-1-11-t3.S"> , <col=520 G = $92 "in_iter"> , <col=522 P = $36 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$97 "<DB.DBA.RDF_QUAD s-1-11-t4>" spec 5> in iterates $100 "in_iter" over ($29 ".no/graphs", $30 ".no/graphs/inferred/nfi/agent-classification", $31 ".no/graphs/inferred/classification", $32 ".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.001 rows Key RDF_QUAD_OGPS ASC ($103 "s-1-6-t5.S") <col=523 O = $28 "phs#OntoGraph"> , <col=520 G = $100 "in_iter"> , <col=522 P = $27 "-ns#type"> , <col=521 S < $26 "callret"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$105 "<DB.DBA.RDF_QUAD s-1-6-t5>" spec 5> from DB.DBA.RDF_QUAD by RDF_QUAD 0.43 rows Key RDF_QUAD ASC ($109 "s-1-19-t6.O", $108 "s-1-19-t6.S", $107 "s-1-19-t6.G") inlined <col=520 G = $103 "s-1-6-t5.S"> , <col=521 S = $95 "s-1-11-t4.S"> , <col=522 P = $34 "ema#label"> Current of: <$111 "<DB.DBA.RDF_QUAD s-1-19-t6>" spec 5> After test: 0: $112 "callret" := Call one_of_these ($107 "s-1-19-t6.G", $30 ".no/graphs/inferred/nfi/agent-classification", $35 ".no/graphs/ontology/mediasone", $32 ".no/graphs/inferred/bildetest/agent-classification", $33 ".no/graphs/inferred/mo/agent-classification") 5: if (<constant (0)> 2(<) $112 "callret") then 9 else 24 unkn 24 9: $113 "callret" := Call __ro2sq ($109 "s-1-19-t6.O") 14: $114 "callret" := Call rdf_regex_impl ($113 "callret", <constant (KJE)>, <constant (i)>) 19: if (<constant (0)> 1(=) $114 "callret") then 24 else 23 unkn 24 23: BReturn 1 24: BReturn 0 After code: 0: $48 "title" := := artm $109 "s-1-19-t6.O" 4: $49 "class" := := artm $108 "s-1-19-t6.S" 8: BReturn 0 Subquery Select($48 "title", $49 "class", <$72 "<DB.DBA.RDF_QUAD s-1-19-t6>" spec 5>, <$66 "<DB.DBA.RDF_QUAD s-1-6-t5>" spec 5>, <$58 "<DB.DBA.RDF_QUAD s-1-7-t2-c5>" spec 5>) } } After code: 0: $122 "callret" := Call __ro2lo ($48 "title") 5: $123 "callret" := Call vector ($49 "class", $122 "callret") 10: $46 "ctor-1" := := artm $123 "callret" 14: BReturn 0 Subquery Select(TOP <constant (10)>) ($46 "ctor-1") } After code: 0: if ($133 "user_aggr_notfirst" 1(=) <constant (1)>) then 15 else 4 unkn 4 4: $133 "user_aggr_notfirst" := := artm <constant (1)> 8: $135 "user_aggr_ret" := Call DB.DBA.SPARQL_CONSTRUCT_INIT ($134 "user_aggr_env") 15: $135 "user_aggr_ret" := Call DB.DBA.SPARQL_CONSTRUCT_ACC ($134 "user_aggr_env", $43 "callret", $46 "ctor-1", $44 "callret", <constant (1)>) 22: BReturn 0 } After code: 0: $136 "callret" := Call DB.DBA.SPARQL_CONSTRUCT_FIN ($134 "user_aggr_env") 7: $137 "callret-0" := Call DB.DBA.RDF_FORMAT_TRIPLE_DICT_AS_TTL ($136 "callret") 14: BReturn 0 Select (TOP <constant (1)>) ($137 "callret-0") } 140 Rows. -- 572 msec. A symptom that something is wrong is that this query returns the following triples: ns1:Xe488b9785022b2d25ac752de2b77e67e rdfs:label "Stormoen, Kjell"^^xsd:string . ns1:Xe227c5d88a40416a251fe478ec20408f rdfs:label "Alver, Kjersti"^^xsd:string . even though that can be interpreted as allowed by the spec. So, the real problem here is that if the LIMIT is set 20 and the OFFSET to 10, there is a triple ns2:X25697d13f2a5b13a86b02d114f5fb4b1 rdfs:label "Rogne, Kjell"^^xsd:string . which makes it impossible to sort the results in the application layer and have paging. Kind regards Kjetil Kjernsmo -- Senior Knowledge Engineer Mobile: +47 986 48 234 Email: kjetil.kjern...@computas.com Web: http://www.computas.com/ | SHARE YOUR KNOWLEDGE | Computas AS PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | Fax:+47 6783 1001