As another virtuoso user.
Can't you make a simpler query without a subselect?

SELECT ?a
FROM NAMED <b
FROM NAMED <i>
{
       GRAPH <b>
       {
          ?c d ?e .
          BIND(REPLACE(STR(?e), "f", "", "i") AS ?g)
          BIND(REPLACE(STR(?c), "f", "", "i") AS ?a)
          FILTER (?g  = STR(?h)) .
       }
       GRAPH <i>
       {
          ?j <k> ?h .
          ?j <l> ?m .
          FILTER (REGEX(STR(?m), "n", "i"))*
       }
}

Mostly what is happening is that the STR casting makes it hard to
optimize the joins as the input could have been anything not just IRIs.

So the following might make things better if ?g and ?h are both supposed 
to be IRI's.

SELECT ?a
FROM NAMED <b
FROM NAMED <i>
{
   GRAPH <b>
   {
     ?c d ?e .
     BIND(IRI(REPLACE(STR(?e), "f", "", "i") AS ?g))
     BIND(REPLACE(STR(?c), "f", "", "i") AS ?a)
   }
   GRAPH <i>
   {
     ?j <k> ?g .
     ?j <l> ?m .
     FILTER (REGEX(STR(?m), "n", "i"))*
   }
}



On 21/04/16 08:42, Pantelis Natsiavas wrote:
> Hello everybody.
>
> I built a SPARQL query using a nested subquery and noticed a huge
> performance penalty. A simplified version of the query follows. Please
> note that in the simplified query presented here I have only replaced
> URIs in order to be more readable and left all the comparisons and
> conversions in place as they could matter to the overall query performance.
>
> SELECT ?a
> FROM NAMED <b>
> {
>      GRAPH <b>
>      {
>         ?c d ?e .
>         BIND(REPLACE(STR(?e), "f", "", "i") AS ?g)
>         BIND(REPLACE(STR(?c), "f", "", "i") AS ?a)
>         FILTER (?g  = STR(?h)) .
>         {
> *SELECT ?h*
> *          FROM NAMED <i>*
> *          WHERE{*
> *              GRAPH <i>*
> *              {*
> *                  ?j <k> ?h .*
> *                  ?j <l> ?m .*
> *                  FILTER (REGEX(STR(?m), "n", "i"))*
> *              }*
> * }*
>         }
>     }
> }
>
> If I execute the above query as a nested query I get a response after 40
> seconds. If I execute the nested query first (shown using bold
> characters) and put the result in the filter of the outer query, I get
> the result in a matter of 3 seconds (total). Given the simplicity of my
> rationale, I would expect a similar logic and performance from virtuoso.
>
> Have you noticed such a performance penalty before? Am I missing
> something? Is there a more efficient way to build the above query? Could
> the above query's performance penalty be caused due to a combination of
> the usage of BIND, REPLACE, STR and nested queries in different graphs?
>
> Please note that I am using Virtuoso Version: 07.20.3214, Build: Oct 14
> 2015 (I built it from source files).
>
> Kind regards,
> Pantelis Natsiavas
>
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>
>
>
> _______________________________________________
> Virtuoso-users mailing list
> Virtuoso-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users
>

-- 
-------------------------------------------------------------------
Jerven Bolleman                        Jerven.Bolleman@sib.swiss
SIB Swiss Institute of Bioinformatics  Tel: +41 (0)22 379 58 85
CMU, rue Michel Servet 1               Fax: +41 (0)22 379 58 58
1211 Geneve 4,
Switzerland     www.sib.swiss - www.uniprot.org
Follow us at https://twitter.com/#!/uniprot
-------------------------------------------------------------------

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to