Hi Eugene,

The profiling support in Query Console is actually quite good for 
diagnosing slow SPARQL queries, have you tried that?

As for getting a SPARQL query plan - at the moment that involves turning 
on a couple of trace flags and looking in the server log. In rough order 
of usefulness, the trace flags are:

SPARQL AST - output the query plan
SPARQL Execution - output the equivalent cts:triples() arguments and 
constraining cts:query for each triple index lookup during query execution.
SPARQL Value Frequencies - output the statistics used during query 
optimization
SPARQL Cost Analysis - output the highlights of query optimization

Trace flags can be turned on under the "Diagnostics" configuration page 
of the host's group in the Admin UI.

In the future we hope to be adding easier ways to understand SPARQL 
query plans and execution. If you have any thoughts on what would help 
you, I'd be pleased to hear them.

John

On 13/12/13 05:41, Siow Boon Lin Eugene wrote:
> Hi,
>
> I did a search on stackoverflow and the documentation but couldn’t find
> any related information.
>
> I’m looking to optimize my SPARQL queries by looking at a query plan for
> them.
>
> I tried something like (in the query console):
>
> xdmp:query-trace(true()),
>
> sem:sparql(my_sparql_query),
>
> xdmp:query-trace(false()),
>
> xdmp:log(xdmp:query-meters)
>
> but I don’t get any results for the query-trace in the error log but I
> get the query-meters results. Is this because the query-trace is only
> for xquery?
>
> I am doing something like this:
>
> PREFIX cts: <http://marklogic.com/cts#>
>
> PREFIX test: <http://test#>
>
> SELECT * WHERE {
>
>                  {
>
>                                  SELECT DISTINCT ?fusedentity ?p {
>
>                                                  ?s ?p ?o.
>
>                                                  filter cts:contains(?o,
> cts:word-query(“test*”))
>
>                                                  ?s a test:Entity1.
>
>                                                  ?fusedentity
> test:hasFusedReference ?s.
>
> } LIMIT 5 OFFSET 0
>
>                  } UNION
>
> {
>
>                  SELECT DISTINCT ?fusedentity ?p {
>
>                                  ?s ?p ?o.
>
>                                  filter cts:contains(?o,
> cts:word-query(“test*”))
>
>                                  ?s a test:Entity2.
>
>                                  ?fusedentity test:hasFusedReference ?s.
>
> } LIMIT 5 OFFSET 0
>
> }
>
> ?fusedentity test:hasFusedReference ?entity.
>
> ?entity a ?class;
>
>                  ?p ?o.
>
> }
>
> The reason for this query is to do a full text search on the triple
> store and return up to 5 results of each class (entity1, entity2) matches.
>
> The query runs quite slowly on a small set of data (<100k triples). The
> index options that I’ve enabled are the trailing wildcard option. Doing
> just a cts:word-query returns in decent time ~1s but after adding the
> other sparql patterns, this can run up to 10s. So I wanted to check the
> query plan to see what I was doing wrong.
>
> I’ve increased the size of the triple cache and triple-value cache. Even
> when there are only triple and triple-value cache hits and no misses,
> the time it takes to return is still ~3-5s. I’ve also increased the
> triple index memory to 200 (it can’t go higher than that, throws an
> error that it is not valid from the admin ui).
>
> Another question I have is also that GROUP BY and statements like
> SAMPLE/MAX/MIN and other aggregates are not in this version as far as
> I’ve tested, is there any other way to do this?
>
> To summarise:
>
> -Is there a way to know the sparql query plan
>
> -Is there a way to speed up the query I’m doing
>
> -Is there a way to do a group by
>
> Thanks and Regards,
>
> Eugene
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>


-- 
John Snelson, Lead Engineer                    http://twitter.com/jpcs
MarkLogic Corporation                         http://www.marklogic.com
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to