Moving SERVICE down in the joins seems to have helped quite a bit:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX acl: <http://www.w3.org/ns/auth/acl#>
PREFIX lacl: <https://w3id.org/atomgraph/linkeddatahub/admin/acl/domain#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX sioc: <http://rdfs.org/sioc/ns#>
DESCRIBE ?auth
FROM <urn:x-arq:UnionGraph>
WHERE
{ { ?auth acl:mode ?Mode
{ ?auth acl:accessTo ?this }
UNION
{ { ?auth acl:accessToClass ?Type }
UNION
{ ?auth acl:accessToClass ?Class .
?Type (rdfs:subClassOf)* ?Class
}
SERVICE ?endpoint
{ { GRAPH ?g
{ ?this a ?Type }
}
}
}
{ { ?auth acl:agent ?agent }
UNION
{ ?auth acl:agentGroup ?Group .
?Group foaf:member ?agent
}
}
}
UNION
{ ?auth acl:mode ?Mode
{ ?auth acl:agentClass foaf:Agent }
UNION
{ ?auth acl:agentClass ?AuthenticatedAgentClass }
{ ?auth acl:accessTo ?this }
UNION
{ { ?auth acl:accessToClass ?Type }
UNION
{ ?auth acl:accessToClass ?Class .
?Type (rdfs:subClassOf)* ?Class
}
SERVICE ?endpoint
{ { GRAPH ?g
{ ?this a ?Type }
}
}
}
}
}
On Sat, Dec 11, 2021 at 12:39 AM Martynas Jusevičius
<[email protected]> wrote:
>
> Hi,
>
> I have query that federates between 2 Fuseki instances (the "remote"
> one is fuseki-end-user):
>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX acl: <http://www.w3.org/ns/auth/acl#>
> PREFIX lacl: <https://w3id.org/atomgraph/linkeddatahub/admin/acl/domain#>
> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> PREFIX sioc: <http://rdfs.org/sioc/ns#>
>
> DESCRIBE ?auth
> FROM <urn:x-arq:UnionGraph>
> WHERE
> { { ?auth acl:mode acl:Read
> { ?auth acl:accessTo
> <https://kg.opendatahub.bz.it/queries/select-ski-resorts/> }
> UNION
> { SERVICE <http://fuseki-end-user:3030/ds/>
> { { GRAPH ?g
> {
> <https://kg.opendatahub.bz.it/queries/select-ski-resorts/>
> a ?Type
> }
> }
> }
> { ?auth acl:accessToClass ?Type }
> UNION
> { ?auth acl:accessToClass ?Class .
> ?Type (rdfs:subClassOf)* ?Class
> }
> }
> { { ?auth acl:agent rdfs:Resource }
> UNION
> { ?auth acl:agentGroup ?Group .
> ?Group foaf:member rdfs:Resource
> }
> }
> }
> UNION
> { ?auth acl:mode acl:Read
> { ?auth acl:agentClass foaf:Agent }
> UNION
> { ?auth acl:agentClass rdfs:Resource }
> { ?auth acl:accessTo
> <https://kg.opendatahub.bz.it/queries/select-ski-resorts/> }
> UNION
> { SERVICE <http://fuseki-end-user:3030/ds/>
> { { GRAPH ?g
> {
> <https://kg.opendatahub.bz.it/queries/select-ski-resorts/>
> a ?Type
> }
> }
> }
> { ?auth acl:accessToClass ?Type }
> UNION
> { ?auth acl:accessToClass ?Class .
> ?Type (rdfs:subClassOf)* ?Class
> }
> }
> }
> }
>
> What I see in the fuseki-end-user log following this query is a bunch
> (200+ in this case) identical requests with this query:
>
> SELECT *
> WHERE
> { GRAPH ?g
> { <https://kg.opendatahub.bz.it/queries/select-ski-resorts/>
> a ?Type
> }
> }
>
> I understand this is due to federation and know that Fuseki does not
> cache the results, but this strikes me as terribly inefficient.
> Each SERVICE request to fuseki-end-user takes around 10 ms but 200+ of
> them add to over 2 seconds.
>
> Is there an opportunity for optimization here? Either of the query or of Jena
> :)
>
> Martynas
> atomgraph.com