On 13/08/12 20:23, Gerald Wagner wrote:
Hi,
I have a problem with query 1 because the query execution always get stuck
while waiting for a result set (I tried it with jena-arq-2.9.1 from command
line and also in a java application). It seems to be a problem with the
query execution plan because query 2 where I'm using a sub select to
retrieve the values of ?SLT is working fine.
Query 1:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :<http://www.test.at/DA.owl#>
SELECT ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV (AVG(DISTINCT
?SLTTV) AS ?AVGTrackValue) (COUNT(DISTINCT ?SLT) AS ?SLTCOUNT)
WHERE {
?Module rdf:type :ServiceModule .
?SLA rdf:type :ServiceLevelAgreement.
?SLO rdf:type :ServiceLevelObjective .
?SLT rdf:type :ServiceLevelTracking .
?Day rdf:type :Day .
?Holiday rdf:type :Holiday .
?rel1 rdf:type :RelationFact .
?rel2 rdf:type :RelationFact .
?rel3 rdf:type :RelationFact .
?rel4 rdf:type :RelationFact .
?rel5 rdf:type :RelationFact .
?Module :hasName ?ModuleName .
?SLA :hasName ?SLAName .
?SLO :hasName ?SLOName .
?SLO :hasType ?SLOType .
?SLO :hasThresholdValue ?SLOTHV .
?SLOType :hasName ?SLOTypeName .
?SLT :hasDayName ?SLTDayName .
?SLT :hasType ?SLTType .
?SLT :hasTrackedDateTime ?trackTime .
?SLT :hasTrackedValue ?SLTTV .
?Day :hasDayName ?DayName .
?Holiday :hasDate ?HolidayDate .
?Holiday :hasStartTime ?HolidayStartTime .
?Holiday :hasEndTime ?HolidayEndTime .
?rel1 :hasParent ?Module .
?rel1 :hasChild ?SLA .
?rel2 :hasParent ?Module.
?rel2 :hasChild ?SLT .
?rel3 :hasParent ?SLA .
?rel3 :hasChild ?SLO .
?rel4 :hasParent ?SLA .
?rel4 :hasChild ?Day .
?rel5 :hasParent ?SLA .
?rel5 :hasChild ?Holiday .
Filter(regex(str(?ModuleName), "E-mail")) .
Filter(?SLOType = ?SLTType) .
Filter(xsd:dateTime(?trackTime) >= xsd:dateTime("2012-08-15T12:00:00")
&& ?trackTime < xsd:dateTime("2012-08-15T13:00:00")) .
Filter(?DayName = ?SLTDayName || (xsd:dateTime("2012-08-15T00:00:00") =
?HolidayDate && xsd:dateTime(?trackTime) >=
xsd:dateTime("2012-08-15T12:00:00") && xsd:dateTime(?trackTime) <
xsd:dateTime("2012-08-15T14:00:00")))
}
GROUP BY ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV
HAVING (?AVGTrackValue < ?SLOTHV)
Query2:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :<http://www.test.at/DA.owl#>
SELECT ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV (AVG(DISTINCT
?SLTTV) AS ?AVGTrackValue) (COUNT(DISTINCT ?SLT) AS ?SLTCOUNT)
WHERE {
?Module rdf:type :ServiceModule .
?SLA rdf:type :ServiceLevelAgreement.
?SLO rdf:type :ServiceLevelObjective .
?Day rdf:type :Day .
?Holiday rdf:type :Holiday .
?rel1 rdf:type :RelationFact .
?rel3 rdf:type :RelationFact .
?rel4 rdf:type :RelationFact .
?rel5 rdf:type :RelationFact .
?Module :hasName ?ModuleName .
?SLA :hasName ?SLAName .
?SLO :hasName ?SLOName .
?SLO :hasType ?SLOType .
?SLO :hasThresholdValue ?SLOTHV .
?SLOType :hasName ?SLOTypeName .
?SLT :hasDayName ?SLTDayName .
?SLT :hasType ?SLTType .
?SLT :hasTrackedDateTime ?trackTime .
?SLT :hasTrackedValue ?SLTTV .
?Day :hasDayName ?DayName .
?Holiday :hasDate ?HolidayDate .
?Holiday :hasStartTime ?HolidayStartTime .
?Holiday :hasEndTime ?HolidayEndTime .
?rel1 :hasParent ?Module .
?rel1 :hasChild ?SLA .
?rel3 :hasParent ?SLA .
?rel3 :hasChild ?SLO .
?rel4 :hasParent ?SLA .
?rel4 :hasChild ?Day .
?rel5 :hasParent ?SLA .
?rel5 :hasChild ?Holiday .
{
SELECT ?SLT ?SLTType ?ModuleName
WHERE {
?SLT rdf:type :ServiceLevelTracking .
?rel2 rdf:type :RelationFact .
?Module :hasName ?ModuleName .
Filter(regex(str(?ModuleName), "E-mail")) .
?rel2 :hasParent ?Module.
?rel2 :hasChild ?SLT
}
}
Filter(?SLOType = ?SLTType) .
Filter(xsd:dateTime(?trackTime) >= xsd:dateTime("2012-08-15T12:00:00") &&
?trackTime < xsd:dateTime("2012-08-15T13:00:00")) .
Filter(?DayName = ?SLTDayName || (xsd:dateTime("2012-08-15T00:00:00") =
?HolidayDate && xsd:dateTime(?trackTime) >=
xsd:dateTime("2012-08-15T12:00:00") && xsd:dateTime(?trackTime) <
xsd:dateTime("2012-08-15T14:00:00")))
}
GROUP BY ?ModuleName ?SLAName ?SLOName ?SLOTypeName ?SLOTHV
HAVING (?AVGTrackValue < ?SLOTHV)
Maybe someone has an idea what the problem is.
(my previous answer elsewhere still applies - the in-memeory query
execution is not very clever in some cases)
The difference is that in query 1 you have
?SLT rdf:type :ServiceLevelTracking .
and
?rel2 rdf:type :RelationFact .
but in query 2 you don't have these until the subSelect..
If you want to use query 1, try reordering and see what happens - moving
the rdf:types to the end might be interesting.
Andy