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)
}