You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by ja...@kolumbus.fi on 2023/05/03 16:58:16 UTC
Combining sparql queries to speed up the calling process ?
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
Re: Combining sparql queries to speed up the calling process ?
Posted by ja...@kolumbus.fi.
Hello,
thanks for encouraging me, just got it working as you said,
Jaana
Andy Seaborne kirjoitti 6.5.2023 18:55:
> On 05/05/2023 11:50, jaanam@kolumbus.fi wrote:
>> Thanks for your answer, but I still don't undestand how to combine
>> those two queries.
>
> I'm not saying they can simply be joined together.
>
> If the FROM tilasto:$STAT is avoided, and the other FROM can be
> removed and GRAPH used then there is probably a single query. That
> depends on the data and data model.
>
> Andy
>
>>
>> If I put them like this jena-fuseki-UI doesn't accept line "{
>> graph tilasto:?ng", because ?ng comes from the 1st subquery.
>
> It may take a LATERAL join but
>
> BIND ( make IRI with tilasto: and ?ng AS ?gn )
> GRAPH ?gn
>
> is a possible way to modify the query.
>
> It does all depend on the data and data model which you are the expert
> for.
>
>>
>>
>> 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, jaanam@kolumbus.fi 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, jaanam@kolumbus.fi 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
Re: Combining sparql queries to speed up the calling process ?
Posted by Andy Seaborne <an...@apache.org>.
On 05/05/2023 11:50, jaanam@kolumbus.fi wrote:
> Thanks for your answer, but I still don't undestand how to combine those
> two queries.
I'm not saying they can simply be joined together.
If the FROM tilasto:$STAT is avoided, and the other FROM can be removed
and GRAPH used then there is probably a single query. That depends on
the data and data model.
Andy
>
> If I put them like this jena-fuseki-UI doesn't accept line "{ graph
> tilasto:?ng", because ?ng comes from the 1st subquery.
It may take a LATERAL join but
BIND ( make IRI with tilasto: and ?ng AS ?gn )
GRAPH ?gn
is a possible way to modify the query.
It does all depend on the data and data model which you are the expert for.
>
>
> 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, jaanam@kolumbus.fi 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, jaanam@kolumbus.fi 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
Re: Combining sparql queries to speed up the calling process ?
Posted by ja...@kolumbus.fi.
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, jaanam@kolumbus.fi 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, jaanam@kolumbus.fi 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
Re: Combining sparql queries to speed up the calling process ?
Posted by Andy Seaborne <an...@apache.org>.
On 04/05/2023 07:18, jaanam@kolumbus.fi 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, jaanam@kolumbus.fi 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
Re: Combining sparql queries to speed up the calling process ?
Posted by ja...@kolumbus.fi.
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)
Br, Jaana
>
> On 03/05/2023 17:58, jaanam@kolumbus.fi 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
Re: Combining sparql queries to speed up the calling process ?
Posted by Andy Seaborne <an...@apache.org>.
Do you have to use FROM in the second query?
On 03/05/2023 17:58, jaanam@kolumbus.fi 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