SPARQL Aggregation Functions Are Slow (Doc ID 1631461.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Spatial and Graph - Version 12.1.0.1 and later
Information in this document applies to any platform.

Symptoms

SPARQL aggregation functions are slow

The following query takes 19 seconds to execute

set timing on
SELECT COUNT(*)
FROM TABLE(SEM_MATCH(
'SELECT (SAMPLE(?s) AS ?s1) (SAMPLE(?p) AS ?p1) ?o
 WHERE
 {
  ?s ?p ?o
 }
 GROUP BY ?o
 HAVING (COUNT(?s) = 1)
',
SEM_Models('test'),
NULL,
NULL,
NULL,
NULL
));

If we avoid the aggregate by using a sub-query it runs in under 2 seconds

SELECT COUNT(*)
FROM TABLE(SEM_MATCH(
'SELECT ?s ?p ?o
 WHERE
 {
  ?s ?p ?o.
  {
  SELECT ?o
  WHERE
  {
  ?s ?p ?o
  }
  GROUP BY ?o
  HAVING (COUNT(?s) = 1)
  }
 }
',
SEM_Models('test'),
NULL,
NULL,
NULL,
NULL
));

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms