Thanks for your thoughts Tony, I was thinking of trying that approach if I couldn't solve this some other way. Like you mentioned, I think that the problem lies somewhere in how ML is optimizing the query, as when I turn off optimization it runs ok.
On Wed, Jul 30, 2014 at 12:12 PM, Anthony Coates <[email protected]> wrote: > Classification: Public > > I don't know what optimisations the ML query engine might apply, but I > normally think of a SPARQL query as evaluating each statement one at a > time, finding all matching triples, and then narrowing down the list of > matching triples as each statement is applied. > > If I read your query correctly, it asks for result relating to all > persons, then results relating to all objects, and only then uses the > relationship to message to filter those down. > > I haven't tried this, but I would be inclined to, say, query on persons, > then query for messages related to each person, then query on objects > related to each message. That might reduce the number of triples in play > during the query (but whether that really matters depends on the internals > of the query engine, about which I know nothing). > > Cheers, Tony. > > > From: Joel Ruisi <[email protected]> To: > [email protected], Date: 30/07/2014 16:30 Subject: [MarkLogic > Dev General] SPARQL Random Timeout > ------------------------------ > > > > I'm having a problem with a SPARQL query that sometimes works fine, and > other times times out. Most of the time it times out. I'm running it > through qconsole using sem:sparql. > > Marklogic Version: 7.0-2.3 > > Here's an example of the query: > > SELECT DISTINCT ?test1 ?test2 ?test3 ?test4 ?test5 ?test6 ?test7 ?graph > FROM NAMED <rdf> > > WHERE { > GRAPH ?graph { > ?person pref:name "Test" . > ?person rdf:type <*http://test/tester.owl#Person* > <http://test/tester.owl#Person>> . > > ?object stef:name ?test1 . > ?object rdf:type equip:Object . > ?object pref:directType ?test5 . > ?object daf:UUID ?test7 . > > ?test4 pref:associatedWith ?person . > ?test4 pref:associatedWith ?object . > ?test4 msg:containedIn ?Message . > > ?Message msg:nodeId ?test6 . > ?Message pref:directType ?test3 . > ?Message msg:messageURI ?test2 . > ?Message rdf:type ?test3 . > ?Message msg:validMessage "true" . > } > } > > I've enabled some trace flags, and here is the output for the failed query: > > [Event:id=SPARQL AST] sessionKey=1530478562463724765 > 2014-07-30 14:07:59.023 Info: plan=SPARQLModule[ > 2014-07-30 14:07:59.023 Info: Prolog[] > 2014-07-30 14:07:59.023 Info: > SPARQLSelect[SPARQLDistinct[SPARQLProject[order() > 2014-07-30 14:07:59.023 Info: GraphNode[Var name 0] > 2014-07-30 14:07:59.023 Info: GraphNode[Var message 1] > 2014-07-30 14:07:59.023 Info: GraphNode[Var messageType 2] > 2014-07-30 14:07:59.023 Info: GraphNode[Var event 3] > 2014-07-30 14:07:59.023 Info: GraphNode[Var equipmentType 4] > 2014-07-30 14:07:59.023 Info: GraphNode[Var nodeId 5] > 2014-07-30 14:07:59.023 Info: GraphNode[Var uniqueId 6] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7] > 2014-07-30 14:07:59.023 Info: SPARQLScatterJoin[order(8,7) > hash(7==7,8==8,10==10) > 2014-07-30 14:07:59.023 Info: SPARQLBloomJoin[order(9,0,7) > hash(7==7,9==9,10==10) > 2014-07-30 14:07:59.023 Info: SPARQLBloomJoin[order(3,10,7) > hash(7==7,8==8) > 2014-07-30 14:07:59.023 Info: TriplePattern[order(8,7) OPS > 2014-07-30 14:07:59.023 Info: GraphNode[Var hvi 8] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test#name* <http://test#name>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Literal "HOLMES"] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]] > 2014-07-30 14:07:59.023 Info: > SPARQLScatterJoin[order(3,10,7) hash(3==3,7==7) > 2014-07-30 14:07:59.023 Info: > SPARQLScatterJoin[order(3,8,7) hash(3==3,7==7) > 2014-07-30 14:07:59.023 Info: > SPARQLBloomJoin[order(9,3,7) hash(7==7,9==9) > 2014-07-30 14:07:59.023 Info: TriplePattern[order(9,7) > OPS > 2014-07-30 14:07:59.023 Info: GraphNode[Var > equipment 9] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://www.w3.org/1999/02/22-rdf-syntax-ns#type* > <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test#Equipment* <http://test#Equipment>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]] > 2014-07-30 14:07:59.023 Info: > TriplePattern[order(9,3,7) OPS > 2014-07-30 14:07:59.023 Info: GraphNode[Var event 3] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test#associatedWith* <http://test#associatedWith>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var > equipment 9] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph > 7]]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(3,8,7) > PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var event 3] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test#associatedWith* <http://test#associatedWith>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var hvi 8] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(3,10,7) > PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var event 3] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/Message.owl#containedIn* > <http://test/Message.owl#containedIn>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var Message 10] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]]] > 2014-07-30 14:07:59.023 Info: SPARQLHashJoin[order(9,0,7) > hash(7==7,9==9) > 2014-07-30 14:07:59.023 Info: SPARQLHashJoin[order(9,6,7) > hash(7==7,9==9) > 2014-07-30 14:07:59.023 Info: SPARQLHashJoin[order(9,4,7) > hash(7==7) > 2014-07-30 14:07:59.023 Info: > SPARQLHashJoin[order(10,1,7) hash(7==7,10==10) > 2014-07-30 14:07:59.023 Info: > SPARQLMergeJoin[order(10,2,7) hash(2==2,7==7,10==10) > 2014-07-30 14:07:59.023 Info: > TriplePattern[order(10,2,7) PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var > Message 10] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://www.w3.org/1999/02/22-rdf-syntax-ns#type* > <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var > messageType 2] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph > 7]] > 2014-07-30 14:07:59.023 Info: > TriplePattern[order(10,2,7) PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var > Message 10] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://www.openrdf.org/schema/sesame#directType* > <http://www.openrdf.org/schema/sesame#directType>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var > messageType 2] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph > 7]]] > 2014-07-30 14:07:59.023 Info: > TriplePattern[order(10,1,7) PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var Message > 10] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/Message.owl#messageURI* <http://test/Message.owl#messageURI> > >] > 2014-07-30 14:07:59.023 Info: GraphNode[Var message > 1] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph > 7]]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(9,4,7) > PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var equipment > 9] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://www.openrdf.org/schema/sesame#directType* > <http://www.openrdf.org/schema/sesame#directType>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var > equipmentType 4] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(9,6,7) > PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var equipment 9] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/daf.owl#UUID* <http://test/daf.owl#UUID>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var uniqueId 6] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(9,0,7) PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var equipment 9] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/stef.owl#name* <http://test/stef.owl#name>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var name 0] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]]] > 2014-07-30 14:07:59.023 Info: SPARQLHashJoin[order(8,7) > hash(7==7) > 2014-07-30 14:07:59.023 Info: SPARQLHashJoin[order(10,5,7) > hash(7==7,10==10) > 2014-07-30 14:07:59.023 Info: TriplePattern[order(10,7) SOP > 2014-07-30 14:07:59.023 Info: GraphNode[Var Message 10] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/Message.owl#validMessage* > <http://test/Message.owl#validMessage>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Literal "true"] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(10,5,7) PSO > 2014-07-30 14:07:59.023 Info: GraphNode[Var Message 10] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/Message.owl#nodeId* <http://test/Message.owl#nodeId>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var nodeId 5] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]] > 2014-07-30 14:07:59.023 Info: TriplePattern[order(8,7) SOP > 2014-07-30 14:07:59.023 Info: GraphNode[Var hvi 8] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://www.w3.org/1999/02/22-rdf-syntax-ns#type* > <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>>] > 2014-07-30 14:07:59.023 Info: GraphNode[IRI < > *http://test/Agent.owl#Person* <http://test/Agent.owl#Person>>] > 2014-07-30 14:07:59.023 Info: GraphNode[Var graph 7]]]]]]]] > > Any help is appreciated, > > Thanks, > > Joel_______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > > > > > > --- > > This e-mail may contain confidential and/or privileged information. If you > are not the intended recipient (or have received this e-mail in error) > please notify the sender immediately and delete this e-mail. Any > unauthorized copying, disclosure or distribution of the material in this > e-mail is strictly forbidden. > > Please refer to http://www.db.com/en/content/eu_disclosures.htm for > additional EU corporate and regulatory disclosures and to > http://www.db.com/unitedkingdom/content/privacy.htm for information about > privacy. > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > >
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
