Very different query plans for very similar queries, involving blank nodes

Query 1 and 2 are similar but Query 1 explicitly uses blank nodes. The query details are attached with their query plans.

I also tried with a query using property paths - performance was pretty bad. I manually killed the execution after 15 secs (300x worse than Query2).

At the times that the OPTIONALs are called in each of the queries - the variables should be bound.

I can modify my queries, but why is this failing?

Query1.txt (8.4 KB)
Query2.txt (7.0 KB)
Query3.txt (7.6 KB)

Hi Andrea,

We need to see the query profiler output to tell for sure (you can get it by adding the --profile flag to query explain). Note that you can still manually kill a query being profiled, the profiler will still collect the partial timings.

Re: queries, Query1 and Query3 (which both don't terminate) are essentially equivalent. There's not difference between ?s :p/:q ?o and ?s :p [ :q ?o ]. But Query2 is not and is substantially simpler because 3 out of 5 OPTIONALs are simple triple patterns and not BGPs of two triple patterns. Query2 can also potentially return different results from 1 and 3 (depends on the data).

Please do the profiling and then we can tell where the problem is.


Pavel, Thanks for the reply. I refactored the code that I was using and rebuilt the databases.

The problem has disappeared ... so, clearly, it was my problem and not yours.

Thanks for the reply.