Those value cache misses are not a problem. The value cache is a per-query atomization cache, so it starts over on every query and misses are to be expected.
Here is a query that doesn't touch the database at all, but the query-meters output still shows the value cache in action. let $a := <x id="1"/> for $i in 1 to 10 return data($a/@id) , xdmp:query-meters() Change the '10' to 5, and watch the query-meters output. -- Mike On 2010-05-19 04:26, Vedavalli Radhika wrote: > Thanks Geert, > The suggestions helped us to fine-tune the query. > Searching for chapter names is part of our requirement. > > Current query: > for $a in cts:search(collection("collection_name"), > cts:and-query((cts:element-attribute-range-query(xs:QName("book"), > xs:QName("length"), ">=", 26), > cts:element-attribute-range-query(xs:QName("book"), xs:QName("length"), "<=", > 2620), cts:element-attribute-value-query(xs:QName("chapter"), > xs:QName("name"), ('chap1','chap2','chap3','chap4')))), ("score-simple")) > > The query change has improved performance by considerable numbers. > However running query-meter for the search query, gives back cache-misses for > value cache. > I am unable to understand where my query went wrong? > > The results are for a 10MB input file. > > Query-trace is also attached. > We have defined two range element attribute indexes(for chapter,name and > book,length) in the marklogic server. > > -<qm:query-meters xsi:schemaLocation="http://marklogic.com/xdmp/query-meters > query-meters.xsd" xmlns:qm="http://marklogic.com/xdmp/query-meters" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <qm:elapsed-time>PT2.369S</qm:elapsed-time> > <qm:requests>0</qm:requests> > <qm:list-cache-hits>264098</qm:list-cache-hits> > <qm:list-cache-misses>0</qm:list-cache-misses> > <qm:in-memory-list-hits>0</qm:in-memory-list-hits> > <qm:expanded-tree-cache-hits>1</qm:expanded-tree-cache-hits> > <qm:expanded-tree-cache-misses>0</qm:expanded-tree-cache-misses> > <qm:compressed-tree-cache-hits>0</qm:compressed-tree-cache-hits> > <qm:compressed-tree-cache-misses>0</qm:compressed-tree-cache-misses> > <qm:in-memory-compressed-tree-hits>0</qm:in-memory-compressed-tree-hits> > <qm:value-cache-hits>1</qm:value-cache-hits> > <qm:value-cache-misses>1</qm:value-cache-misses> > <qm:regexp-cache-hits>0</qm:regexp-cache-hits> > <qm:regexp-cache-misses>0</qm:regexp-cache-misses> > <qm:link-cache-hits>0</qm:link-cache-hits> > <qm:link-cache-misses>0</qm:link-cache-misses> > <qm:filter-hits>1</qm:filter-hits> > <qm:filter-misses>0</qm:filter-misses> > <qm:fragments-added>0</qm:fragments-added> > <qm:fragments-deleted>0</qm:fragments-deleted> > <qm:fs-program-cache-hits>0</qm:fs-program-cache-hits> > <qm:fs-program-cache-misses>0</qm:fs-program-cache-misses> > <qm:db-program-cache-hits>0</qm:db-program-cache-hits> > <qm:db-program-cache-misses>0</qm:db-program-cache-misses> > > <qm:fs-main-module-sequence-cache-hits>0</qm:fs-main-module-sequence-cache-hits> > > <qm:fs-main-module-sequence-cache-misses>0</qm:fs-main-module-sequence-cache-misses> > > <qm:db-main-module-sequence-cache-hits>0</qm:db-main-module-sequence-cache-hits> > > <qm:db-main-module-sequence-cache-misses>0</qm:db-main-module-sequence-cache-misses> > <qm:fs-library-module-cache-hits>0</qm:fs-library-module-cache-hits> > <qm:fs-library-module-cache-misses>0</qm:fs-library-module-cache-misses> > <qm:db-library-module-cache-hits>0</qm:db-library-module-cache-hits> > <qm:db-library-module-cache-misses>0</qm:db-library-module-cache-misses> > -<qm:fragments> > -<qm:fragment> > <qm:root>book</qm:root> > <qm:expanded-tree-cache-hits>1</qm:expanded-tree-cache-hits> > <qm:expanded-tree-cache-misses>0</qm:expanded-tree-cache-misses> > </qm:fragment> > </qm:fragments> > -<qm:documents> > -<qm:document> > <qm:uri>testbook</qm:uri> > <qm:expanded-tree-cache-hits>1</qm:expanded-tree-cache-hits> > <qm:expanded-tree-cache-misses>0</qm:expanded-tree-cache-misses> > </qm:document> > </qm:documents> > </qm:query-meters> > > Results from query-trace > > 2010-05-19 12:54:37.876 Info: Http_Server: line 1: > xdmp:eval("xdmp:query-trace(true()), > cts:search(collection("collection_name&qu...", (),<options > xmlns="xdmp:eval"><root>C:\Program > Files\MarkLogic\Samples\cq</root><isolation>dif...</options>) > 2010-05-19 12:54:37.876 Info: Http_Server: line 1: Analyzing path for search: > fn:collection("collection_name") > 2010-05-19 12:54:37.876 Info: Http_Server: line 1: Step 1 is searchable: > fn:collection("collection_name") > 2010-05-19 12:54:37.876 Info: Http_Server: line 1: Path is fully searchable. > 2010-05-19 12:54:37.876 Info: Http_Server: line 1: Gathering constraints. > 2010-05-19 12:54:37.876 Info: Http_Server: line 1: Step 1 contributed 1 > constraint: fn:collection("collection_name") > 2010-05-19 12:54:39.431 Info: Http_Server: line 1: Comparison contributed int > range value constraint: book/@length<mailto:book/@length> >= 48754 > 2010-05-19 12:54:39.431 Info: Http_Server: line 1: Comparison contributed int > range value constraint: book/@length<mailto:book/@length> <= 487542500 > 2010-05-19 12:54:40.059 Info: Http_Server: line 1: Search query contributed 2 > constraints: cts:and-query((cts:element-attribute-range-query(fn:QName("", > "book"), fn:QName("", "length"), ">=", 48754, (), 1), > cts:element-attribute-range-query(fn:QName("", "book"), fn:QName("", > "length"), "<=", 487542500, (), 1), > cts:element-attribute-value-query(fn:QName("", "chapter"), fn:QName("", > "name"), ("chap1", "chap2", "chap3", "chap4",....), ("lang=en"), 1)), ()) > 2010-05-19 12:55:24.935 Info: Http_Server: line 1: Executing search. > 2010-05-19 12:55:25.240 Info: Http_Server: line 1: Selected 4 fragments to > filter > > Thanks, > Radhika > > > > Hi Radhika, > > Glancing through your query I notice some things. You have a nested > and-query, do you know that cts:and-query can take an sequence of any length? > And you have an or-query that tests the same element attribute value over and > over again, with different values. It should be possible to pass one sequence > with all allowed values to a single cts:element-attribute-value-query, > eliminating the need for the or-query alltogether. > > Not sure why you are searching for specific chapter names though. Is that > necessary? > > Kind regards, > Geert > >> > > drs. G.P.H. (Geert) Josten > Consultant > > Daidalos BV > Hoekeindsehof 1-4 > 2665 JZ Bleiswijk > > T +31 (0)10 850 1200 > F +31 (0)10 850 1199 > > mailto:geert.jos...@daidalos.nl > http://www.daidalos.nl/ > > KvK 27164984 > > P Please consider the environment before printing this mail. > De informatie - verzonden in of met dit e-mailbericht - is afkomstig van > Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit > bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit > bericht kunnen geen rechten worden ontleend. > >> From: >> general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> >> [mailto:general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>] >> On Behalf Of >> Vedavalli Radhika >> Sent: maandag 17 mei 2010 13:53 >> To: general@developer.marklogic.com<mailto:general@developer.marklogic.com> >> Subject: [MarkLogic Dev General] Performance Tuning - >> cts:search/cts:or Query >> >> We have a requirement for searching the marklogic database >> for documents that satisfies a specific condition - length >> attribute value should be within the specified range and one >> or more chapters from the given chapters should be available. >> The searched information is then filtered based on a fitness >> calculation. >> The execution of the query takes a long time if the dynamic >> or-query becomes long (for bigger inputs, the or-query formed >> will be longer) Are there better ways to optimize this search >> query or atleast the or-query alone? >> >> QUERY: >> for $a in >> cts:search(collection(), >> cts:and-query( >> ( >> cts:and-query( >> (cts:element-attribute-range-query(xs:QName("book"), >> xs:QName("length"), ">=", 26), >> cts:element-attribute-range-query(xs:QName("book"), >> xs:QName("length"), "<=", 2620)) ), cts:or-query( ( >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap6"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "newChap"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap2"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap5"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap3"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap9"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap1"), >> cts:element-attribute-value-query(xs:QName("chapter"), >> xs:QName("name"), "chap4")) >> ) >> ) >> ), ("score-simple")) >> where $a[(cts:score($a))div(8*($a/book/@chapCnt<mailto:$a/book/@chapCnt>)) >> ge 0.1] >> return element hit { attribute score { cts:score($a) }, $a } >> SAMPLE DOCUMENT IN MARKLOGIC: >> <book author="Author" length="262" id="unique-id" chapCnt="4"> >> <chapter pageStart="5" name="chap1" pageEnd="80" /> >> <chapter pageStart="83" name="chap2" pageEnd="180" /> >> <chapter pageStart="182" name="chap3" pageEnd="401" /> >> <chapter pageStart="405" name="chap4" pageEnd="567" /> >> </book> >> >> Thanks, >> Radhika >> >> > _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general