Thanks for your answer, but I still don't undestand how to combine those two queries.

If I put them like this jena-fuseki-UI doesn't accept line "{ graph tilasto:?ng", because ?ng comes from the 1st subquery.


SELECT *

WHERE {

          {

              {

                   GRAPH stat:outputchannel

                        {

                       ?subject outchl:refersToTable ?t_id .

                        ?subject outchl:refersToNamedGraph ?ng .

                        ?subject outchl:hasOutputFileId ?o_id.

                        filter (regex(?o_id,"of_001"))

                        }

                }

           }



      { graph tilasto:?ng

        {

            ?pxfile pxt:tableId "?t_id".

             ?pxfile pxt:isPresentationOf ?cube.

             ?cube dc:description ?title_fi.

             ?cube cubemeta:refersToOutputFile ?of.

          }

    }

    { graph stat:outputchannel

        {

            ?subject outchl:hasOutputFileId ?of.

             ?subject outchl:refersToOutputChannel ?channel_prefix .

            ?subject outchl:refersToTable ?t_id .

              ?subject outchl:refersToNamedGraph ?ng .

            ?subject outchl:hasOutputFileId ?o_id.

           }

      }

    { graph stat:tabAdmin

       {

        ?kanta outchl:hasOutputChannelId ?channel_prefix .

        ?kanta outchl:directoryPathRoot ?directoryPathRoot .

       }

  }

}

Can you help ?

Br, Jaana

Andy Seaborne kirjoitti 4.5.2023 13:14:
On 04/05/2023 07:18, [email protected] wrote:
Andy Seaborne kirjoitti 4.5.2023 00:24:
Do you have to use FROM in the second query?

I don't know how to present it because in the 2nd query I'm querying three named graphs, where the third one ($STAT) should be replaced with the result of the 1st query (?ng)


But do you need a merged graph or can you use GRAPH? FROM of multiple
graphs may be a significant cost.  (It precludes TDB executing more
directly on basic graph patterns.)

With GRAPH ?g you can apply a condition to the ?g.
And that means you can combine the queries which might help - to know,
needs an experiment.

---

3000 queries in 5 mins is 100ms a query, including client and server overheads.

Are you doing the 3000 queries in parallel? A bit of parallelism might
save elapsed time (start with parallel = 2).

    Andy

Br, Jaana


On 03/05/2023 17:58, [email protected] wrote:
Hello,

I have the two queries below which I run from my code so that the 1st query returns about 3000  ?ng and ?t_id pairs which will then be used in the second query in the place of $STAT and $RDF_ID. So I'm calling the second query in a loop about 3000 times.

I've noticed that it is time consuming; it takes about 4-5 minutes. How could I combine the queries so that I could get all the information by just one call ?

$PREFIXS
     SELECT *
     WHERE
           {
               {
                    GRAPH stat:outputchannel
                         {
                             ?subject outchl:refersToTable ?t_id .
                        ?subject outchl:refersToNamedGraph ?ng .
                       ?subject outchl:hasOutputFileId ?o_id.
                 filter (regex(?o_id,"of_001"))
                         }
                 }
            }


and

$PREFIXS

    SELECT *
    FROM stat:outputchannel
    FROM stat:tabAdmin
    FROM tilasto:$STAT
    WHERE {
      ?pxfile pxt:tableId "$RDF_ID".
        ?pxfile pxt:hasStatus ?status.
      ?pxfile pxt:hasFrequency ?frequency.
      ?pxfile pxt:isPresentationOf ?cube.
      ?cube dc:description ?title_fi.
      ?cube dc:language ?language.
          ?cube cubemeta:hasStatisticalProgramme ?statisticalProgram.
          ?cube cubemeta:lastUpdated ?lastUpdated.
          ?cube cubemeta:refersToOutputFile ?of.
          ?subject outchl:hasOutputFileId ?of.
      ?subject outchl:refersToOutputChannel ?channel_prefix .
      ?kanta outchl:hasOutputChannelId ?channel_prefix .
          ?kanta outchl:directoryPathRoot ?directoryPathRoot .
      ?kanta a outchl_ont:OutputChannel .
        filter(?language ="fi"^^xsd:language)
          filter (lang(?title_fi) = "fi")
      filter ( langMatches(lang(?directoryPathRoot),"fi") )
}

Br jaana M

Reply via email to