Hi, Basu:

Instead of putting many articles and contributors in a single document
and using XPath to extract the articles and contributors from the
document, have you explored putting each entity in a separate
document and relying on search to give you just the entities you need?

(For those coming from a relational background, the usual guidance
is treat a document as a row instead of as a table.)

The benefit is not only in getting the full benefit of the indexes
in accelerating retrieval and minimizing load but also in avoiding
contention.  (Updates apply to the same document much less
frequently if documents are small.)

Retrieving large data sets to the application to filter on the client is
likely to be quite inefficient and increase load.


Hoping that helps,



Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of Basavaraj Kalloli 
[[email protected]]
Sent: Monday, August 14, 2017 4:34 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Optimizing XPath Equals Performance

Hi,

We have been following up with our on going performance problems and we found 
that we are looking up a bunch of documents in Marklogic and then doing an 
XPath equals on each of them to find all the nodes that match a contributor, 
the query is:

declare namespace npg="....";
declare namespace rdf="....";

let $uri := cts:uri-match('*blah*')
let $record := doc($uri)
let $article := $record//semantic-metadata/graph/rdf:RDF/npg:Article
let $contributors := $article/npg:hasContributor/@rdf:resource
return $record//semantic-metadata/graph/rdf:RDF/npg:Contributor[@rdf:about eq 
$article/npg:hasContributor/@rdf:resource]

The number of contributors in the above case where 3054 so I am looking up all 
the contributor nodes (which could be more) in the document and matching any of 
the 3054.

My understanding is that we are not doing a search but instead loading the 
whole document and doing a comparison on all the contributor nodes hence adding 
any indexes is not going to help? Or is there a smarter way of doing this that 
I don't know about? Any help would appreciated, these sort of queries are 
really killing our MarkLogic cluster.

One other option would be potentially move this outside of xquery and do in the 
app rather than using up Marklogic resources which could be used for search 
queries instead.

Thanks,
Basu
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to