Re: [3.16.0] Repeating identical queries from SERVICE

2021-12-10 Thread Martynas Jusevičius
Moving SERVICE down in the joins seems to have helped quite a bit:

PREFIX  rdfs: 
PREFIX  acl:  
PREFIX  lacl: 
PREFIX  foaf: 
PREFIX  sioc: 

DESCRIBE ?auth
FROM 
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
 wrote:
>
> Hi,
>
> I have query that federates between 2 Fuseki instances (the "remote"
> one is fuseki-end-user):
>
> PREFIX  rdfs: 
> PREFIX  acl:  
> PREFIX  lacl: 
> PREFIX  foaf: 
> PREFIX  sioc: 
>
> DESCRIBE ?auth
> FROM 
> WHERE
>   {   { ?auth  acl:mode  acl:Read
>   { ?auth  acl:accessTo
>  }
> UNION
>   { SERVICE 
>   { { GRAPH ?g
> { 
> 
> 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
>  }
> UNION
>   { SERVICE 
>   { { GRAPH ?g
> { 
> 
> 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
>   { 
>   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


[3.16.0] Repeating identical queries from SERVICE

2021-12-10 Thread Martynas Jusevičius
Hi,

I have query that federates between 2 Fuseki instances (the "remote"
one is fuseki-end-user):

PREFIX  rdfs: 
PREFIX  acl:  
PREFIX  lacl: 
PREFIX  foaf: 
PREFIX  sioc: 

DESCRIBE ?auth
FROM 
WHERE
  {   { ?auth  acl:mode  acl:Read
  { ?auth  acl:accessTo
 }
UNION
  { SERVICE 
  { { GRAPH ?g
{ 
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
 }
UNION
  { SERVICE 
  { { GRAPH ?g
{ 
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
  { 
  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