But still, it is interesting, that I could resolve my initial problem with your workaround #pragma reasoning off and without using stored queries, just using these lines within the complicated query:
?rs rdfs:subClassOf sct:3898006 .
?rt rdfs:subClassOf sct:64033007 .
But if I run the same with stored queries:
SERVICE <query://SNOMEDSubclass> {
[] sqs:vars ?rs ;
sqs:var:iri sct:3898006 ;
}
SERVICE <query://SNOMEDSubclass> {
[] sqs:vars ?rt ;
sqs:var:iri sct:64033007 ;
}
it takes approx. double the time, but I get an empty list.
The plan for the stored queries is this one:
prefix sqs: tag:stardog:api:sqs:
Slice(offset=0, limit=1000) [#1.0K]
`ā Distinct [#3.1K]
`ā Projection(?label) [#3.1K]
`ā Filter(?rr IN(?rt)) [#3.1K]
`ā NestedLoopJoin(_) [#6.3K]
+ā Filter(?ss IN(?rs)) [#2.5K]
ā `ā NestedLoopJoin(_) [#5.0K]
ā +ā MergeJoin(?subject) [#67]
ā ā +ā Scan[PSOC](?subject, <http://www.w3.org/2000/01/rdf-schema#label>, ?label) [#354K]
ā ā `ā MergeJoin(?subject) [#67]
ā ā +ā Scan[POSC](?subject, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/07/owl#Class>) [#683K]
ā ā `ā Sort(?subject) [#11]
ā ā `ā MergeJoin(?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d) [#11]
ā ā +ā Scan[PSC](?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d, <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>, _) [#742K]
ā ā `ā Sort(?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d) [#10]
ā ā `ā HashJoin(?_listNode_d89bc719_b071_4fab_8182_e64f25c07685) [#10]
ā ā +ā MergeJoin(?_anon_6) [#182]
ā ā ā +ā MergeJoin(?_anon_6) [#16K]
ā ā ā ā +ā Scan[POSC](?_anon_6, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/07/owl#Class>) [#683K]
ā ā ā ā `ā Sort(?_anon_6) [#7.7K]
ā ā ā ā `ā MergeJoin(?_listNode_d89bc719_b071_4fab_8182_e64f25c07685) [#7.7K]
ā ā ā ā +ā Scan[POSC](?_listNode_d89bc719_b071_4fab_8182_e64f25c07685, <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>) [#329K]
ā ā ā ā `ā Sort(?_listNode_d89bc719_b071_4fab_8182_e64f25c07685) [#20K]
ā ā ā ā `ā MergeJoin(?_list_bd43126e_6c05_4d2a_9502_f68125b31859) [#20K]
ā ā ā ā +ā Scan[POSC](?_anon_6, <http://www.w3.org/2002/07/owl#intersectionOf>, ?_list_bd43126e_6c05_4d2a_9502_f68125b31859) [#329K]
ā ā ā ā `ā MergeJoin(?_list_bd43126e_6c05_4d2a_9502_f68125b31859) [#54K]
ā ā ā ā +ā Scan[PSOC](?_list_bd43126e_6c05_4d2a_9502_f68125b31859, <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>, ?_listNode_d89bc719_b071_4fab_8182_e64f25c07685) [#873K]
ā ā ā ā `ā Sort(?_list_bd43126e_6c05_4d2a_9502_f68125b31859) [#54K]
ā ā ā ā `ā MergeJoin(?_anon_8) [#54K]
ā ā ā ā +ā Scan[POSC](?_list_bd43126e_6c05_4d2a_9502_f68125b31859, <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>, ?_anon_8) [#873K]
ā ā ā ā `ā MergeJoin(?_anon_8) [#60K]
ā ā ā ā +ā Scan[PSOC](?_anon_8, <http://www.w3.org/2002/07/owl#someValuesFrom>, ?ss) [#698K]
ā ā ā ā `ā MergeJoin(?_anon_8) [#59K]
ā ā ā ā +ā Scan[POSC](?_anon_8, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/07/owl#Restriction>) [#698K]
ā ā ā ā `ā Scan[POSC](?_anon_8, <http://www.w3.org/2002/07/owl#onProperty>, <http://snomed.info/id/116676008>) [#59K]
ā ā ā `ā Sort(?_anon_6) [#13K]
ā ā ā `ā MergeJoin(?_anon_5) [#13K]
ā ā ā +ā MergeJoin(?_anon_5) [#213K]
ā ā ā ā +ā Scan[PSOC](?_anon_5, <http://www.w3.org/2002/07/owl#someValuesFrom>, ?_anon_6) [#698K]
ā ā ā ā `ā MergeJoin(?_anon_5) [#213K]
ā ā ā ā +ā Scan[POSC](?_anon_5, <http://www.w3.org/2002/07/owl#onProperty>, <http://snomed.info/id/609096000>) [#213K]
ā ā ā ā `ā Scan[POSC](?_anon_5, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/07/owl#Restriction>) [#698K]
ā ā ā `ā Sort(?_anon_5) [#56K]
ā ā ā `ā MergeJoin(?_listNode_2cc923dd_2306_460d_b9a9_62050be28942) [#56K]
ā ā ā +ā MergeJoin(?_listNode_2cc923dd_2306_460d_b9a9_62050be28942) [#329K]
ā ā ā ā +ā Scan[POSC](?_listNode_2cc923dd_2306_460d_b9a9_62050be28942, <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>) [#329K]
ā ā ā ā `ā Scan[PSOC](?_listNode_2cc923dd_2306_460d_b9a9_62050be28942, <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>, ?_anon_5) [#873K]
ā ā ā `ā Sort(?_listNode_2cc923dd_2306_460d_b9a9_62050be28942) [#184K]
ā ā ā `ā MergeJoin(?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d) [#184K]
ā ā ā +ā Scan[PSOC](?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d, <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>, ?_listNode_2cc923dd_2306_460d_b9a9_62050be28942) [#873K]
ā ā ā `ā Sort(?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d) [#184K]
ā ā ā `ā MergeJoin(?_anon_3) [#184K]
ā ā ā +ā Scan[POSC](?_anon_3, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/07/owl#Class>) [#683K]
ā ā ā `ā MergeJoin(?_anon_3) [#120K]
ā ā ā +ā Scan[PSOC](?_anon_3, <http://www.w3.org/2002/07/owl#intersectionOf>, ?_list_ba28ede0_06a4_48a8_bca8_a9af4fb92e7d) [#329K]
ā ā ā `ā Scan[POSC](?subject, <http://www.w3.org/2002/07/owl#equivalentClass>, ?_anon_3) [#120K]
ā ā `ā MergeJoin(?_anon_9) [#64K]
ā ā +ā Scan[POSC](?_listNode_d89bc719_b071_4fab_8182_e64f25c07685, <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>, ?_anon_9) [#873K]
ā ā `ā MergeJoin(?_anon_9) [#76K]
ā ā +ā Scan[POSC](?_anon_9, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/07/owl#Restriction>) [#698K]
ā ā `ā MergeJoin(?_anon_9) [#76K]
ā ā +ā Scan[POSC](?_anon_9, <http://www.w3.org/2002/07/owl#onProperty>, <http://snomed.info/id/363698007>) [#76K]
ā ā `ā Scan[PSOC](?_anon_9, <http://www.w3.org/2002/07/owl#someValuesFrom>, ?rr) [#698K]
ā `ā StoredQuery(SNOMEDSubclass) {
ā +ā iri -> sct:3898006
ā +ā rs -> ?rs
ā +ā prefix sct: <http://snomed.info/id/>
ā +ā
ā +ā Projection(?rt)
ā +ā `ā Scan[SPO](?rt, <http://www.w3.org/2000/01/rdf-schema#subClassOf>, ?iri)
ā }
`ā StoredQuery(SNOMEDSubclass) {
+ā iri -> sct:64033007
+ā rt -> ?rt
+ā prefix sct: <http://snomed.info/id/>
+ā
+ā Projection(?rt)
+ā `ā Scan[SPO](?rt, <http://www.w3.org/2000/01/rdf-schema#subClassOf>, ?iri)
}