2017-02-14 18 views
2

我通過MLCP命令在我的數據庫中插入了200000個xml文檔(大約總大小爲1GB)。現在我想在該數據庫的搜索查詢下運行(數據庫,在admin api中使用默認索引設置)以獲取所有文檔。marklogic 8在我的數據庫中插入大量xml文件後,查詢性能下降

let $options := 
<options xmlns="http://marklogic.com/appservices/search"> 
    <search-option>unfiltered</search-option> 
    <term> 
    <term-option>case-insensitive</term-option> 
    </term> 
    <constraint name="Title"> 
     <range collation="http://marklogic.com/collation/" facet="true"> 
     <element ns="http://learning.com" name="title" /> 
     </range> 
    </constraint> 
    <constraint name="Keywords"> 
     <range collation="http://marklogic.com/collation/" facet="true"> 
     <element ns="http://learning.com" name="subjectKeyword" /> 
     </range> 
    </constraint> 
    <constraint name="Subjects"> 
     <range collation="http://marklogic.com/collation/" facet="true"> 
     <element ns="http://learning.com" name="subjectHeading" /> 
     </range> 
    </constraint> 
    <return-results>true</return-results> 
    <return-query>true</return-query> 
</options> 
let $result := search:search("**", $options, 1, 20) 
return $result 

範圍指數: -

 <range-element-index> 
     <scalar-type>string</scalar-type> 
     <namespace-uri>http://learning.com</namespace-uri> 
     <localname>title</localname> 
     <collation>http://marklogic.com/collation/</collation> 
     <range-value-positions>false</range-value-positions> 
     <invalid-values>ignore</invalid-values> 
    </range-element-index> 
     <range-element-index> 
     <scalar-type>string</scalar-type> 
     <namespace-uri>http://learning.com</namespace-uri> 
     <localname>subjectKeyword</localname> 
     <collation>http://marklogic.com/collation/</collation> 
     <range-value-positions>false</range-value-positions> 
     <invalid-values>ignore</invalid-values> 
    </range-element-index> 
      <range-element-index> 
     <scalar-type>string</scalar-type> 
     <namespace-uri>http://learning.com</namespace-uri> 
     <localname>subjectHeading</localname> 
     <collation>http://marklogic.com/collation/</collation> 
     <range-value-positions>false</range-value-positions> 
     <invalid-values>ignore</invalid-values> 
    </range-element-index> 

在每個XML文檔subjectkeyword和標題值就像是

<lmm:subjectKeyword>anatomy, biology, illustration, cross, section, digestive, human, circulatory, body, small, neck, head, ear, torso, veins, teaching, model, deep, descending, heart, brain, muscles, lungs, diaphragm, c</lmm:subjectKeyword><lmm:title>CORTY_EQ07-014.eps</lmm:title> 

但它拍了很多時間,甚至查詢控制檯說太多元素渲染解析器錯誤:無法解析結果。文件大小太大

回答

2

分頁確實是關鍵,我很好奇你的方面,我想你的例子中,「Title」在你的200k文檔中幾乎總是唯一的,而lmm :subjectKeyword元素看起來好像需要一些小的後期處理以使它作爲一個方面更有用 - 它是一串逗號分隔的值,這意味着subjectKeyword幾乎總是獨一無二的(我建議將這些值分別放入一個單獨的值中元素,這將是多莫e作爲一個方面有用)。而且我猜題目主題也是獨一無二的。

當您擁有一組有限的值時,構面通常很有用 - 例如,對於筆記本電腦來說,有限套餐包括製造商,顯示器尺寸和價格範圍內的存儲桶。一旦你進入了數百個價值觀,一個方面的效用就會減少 - 有多少用戶真正想要通過數百或數千個價值進行排序以找到他們想要的東西?而就你而言,我們可能談論的是數以萬計的獨特價值,如果不是200k的獨特價值(特別是對於「標題」)。而且 - 當你擁有許多獨特的價值時,方面解決時間將需要更長的時間。

因此,在探索facet解決時間之前 - 您試圖用這三個方面解決什麼問題?

如果不知道更多,我會將該SubjectKeyword元素後處理成許多元素,每個元素都有一個關鍵字,然後在該元素上添加一個方面。理想情況下,你有幾十個關鍵字,可能有幾百個,解決這個問題應該是非常快的。

+0

謝謝@rjrudin重播,我打算按照你的建議過程,像subjectKeyword元素到許多元素中,每個元素都有一個關鍵字 – Raj

+0

但是對於標題,它並不是在你的200k文檔中唯一。它包含具有「_」,「 - 」,「。」等字符的值。在每個文件中。這些字符降低了我的處理時間。那我怎麼處理它? – Raj

+0

爲什麼你想在標題方面? – rjrudin

3

首先,不要試圖一次獲取所有文檔。這意味着MarkLogic必須爲每個文檔,進程以及序列化進入磁盤,最後但並非最不重要的是,客戶端也需要接收和顯示。後者可能是這裏的瓶頸。這通常是用戶應用程序一次顯示10或20個搜索結果的原因。換句話說:使用分頁。

我也建議運行未經過濾的更好的性能。

HTH!

+0

感謝@Geert您的建議現在我在您的路上實現搜索:搜索(「**」,$ options,1,20)和它的工作正常。但現在我需要在方面添加範圍元素約束,並且我在admin上創建了範圍索引,但我在獲得價值時面臨同樣的性能問題。我將我的代碼更改爲 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/1773872/">Raj</a></span> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+1</span></div> <div class="col-lg-11"> <p class="commenttext">@Raj而不是更改此問題以添加新的要求,請創建一個新問題。如果問題和答案之間沒有直接關係,那麼對於其他SO用戶來說,這是令人困惑的。 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/1226554/">wst</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">4<i class="fa fa-thumbs-up"></i></span> </div> <div class="post-offset"> <div class="answer fmt"> <p>我還想補充一點,如果你想獲取所有文檔(我不會推薦在一個非平凡的數據庫上),直接做它而不是通配符搜索會更有效率:<code class="prettyprint-override">fn:doc()</code>(或,正如Geert所建議的那樣,分頁:<code class="prettyprint-override">fn:doc[1 to 20]</code></p> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/42229785">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2017-02-14 15:17:34</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/937585/">mholstege</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> </div> </article> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-mkuwlotx-yv.html" target="_blank" title="在插入大塊數據後Sql Express上的性能下降"> 在插入大塊數據後Sql Express上的性能下降 </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-hdkkuzpg-bac.html" target="_blank" title="大索引插入性能下降(MYSQL)"> 大索引插入性能下降(MYSQL) </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-kmtasxmd-bbh.html" target="_blank" title="Sql查詢性能下降"> Sql查詢性能下降 </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-suallqnk-xg.html" target="_blank" title="elasticsearch查詢性能下降"> elasticsearch查詢性能下降 </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-pkgunfyc-hw.html" target="_blank" title="Elasticsearch在源域中對大量數據檢索性能下降"> Elasticsearch在源域中對大量數據檢索性能下降 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-edwdkiot-kw.html" target="_blank" title="XML解析:將XML數據插入到數據庫中:性能"> XML解析:將XML數據插入到數據庫中:性能 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-rfsxpnft-gz.html" target="_blank" title="LINQ查詢中的性能下降"> LINQ查詢中的性能下降 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-nolhmory-bho.html" target="_blank" title="數據清除後MySQL數據庫性能下降"> 數據清除後MySQL數據庫性能下降 </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-vicarfad-wt.html" target="_blank" title="BlackBerry數據庫性能下降"> BlackBerry數據庫性能下降 </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-apnfcizi-ho.html" target="_blank" title="讀取大型XML文件並將數據插入數據庫"> 讀取大型XML文件並將數據插入數據庫 </a> </li> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-undqnxle-bhd.html" target="_blank" title="插入XML到SQL Server數據庫,然後查詢它"> 插入XML到SQL Server數據庫,然後查詢它 </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-bjdesvsh-xk.html" target="_blank" title="在MySQL數據庫中插入查詢"> 在MySQL數據庫中插入查詢 </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-nnuatvmb-tm.html" target="_blank" title="在單個事務中插入多行時,Oracle查詢性能下降"> 在單個事務中插入多行時,Oracle查詢性能下降 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-omfktaro-yc.html" target="_blank" title="MySQL的性能下降聯接查詢"> MySQL的性能下降聯接查詢 </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-mfkhuero-tu.html" target="_blank" title="MySQL在大表上插入性能下降"> MySQL在大表上插入性能下降 </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-cnddmtun-bde.html" target="_blank" title="插入查詢未插入數據庫"> 插入查詢未插入數據庫 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-nhhnbjij-wk.html" target="_blank" title="MySql SELECT在巨大的數據庫中查詢性能問題"> MySql SELECT在巨大的數據庫中查詢性能問題 </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-xizzsodg-bng.html" target="_blank" title="將MS Access數據庫導入到SQL Server的性能下降"> 將MS Access數據庫導入到SQL Server的性能下降 </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-hfadtqbd-ug.html" target="_blank" title="爲什麼我的PHP MySQLi查詢不能插入數據庫?"> 爲什麼我的PHP MySQLi查詢不能插入數據庫? </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-pfohgeed-bmc.html" target="_blank" title="爲什麼我的Azure SQL數據庫性能突然下降?"> 爲什麼我的Azure SQL數據庫性能突然下降? </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-mxgplmzo-qo.html" target="_blank" title="在Coldfusion中插入大量數據而沒有循環查詢"> 在Coldfusion中插入大量數據而沒有循環查詢 </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-tfcuhuse-bma.html" target="_blank" title="重複查詢時性能下降?"> 重複查詢時性能下降? </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-dvnzwyoi-ph.html" target="_blank" title="工作LINQ查詢,但性能下降"> 工作LINQ查詢,但性能下降 </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-pvbdvclv-dk.html" target="_blank" title="與SQL查詢性能下降"> 與SQL查詢性能下降 </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-ukqzocyi-kb.html" target="_blank" title="查詢性能下降,因爲Row_Number()"> 查詢性能下降,因爲Row_Number() </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-elrejekr-ea.html" target="_blank" title="MarkLogic 8 - XQuery - cts查詢按值查找文檔屬性"> MarkLogic 8 - XQuery - cts查詢按值查找文檔屬性 </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-kzplmwgw-hx.html" target="_blank" title="未能查詢數據庫表中的最大數量"> 未能查詢數據庫表中的最大數量 </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-yrsduwnf-tx.html" target="_blank" title="大頁面性能下降"> 大頁面性能下降 </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-maqvufop-ku.html" target="_blank" title="數據庫日誌文件在破壞後成長大量插入C#"> 數據庫日誌文件在破壞後成長大量插入C# </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-uiciiizj-eb.html" target="_blank" title="sql性能下降 - 加載60,000 xml文件 - ssis - xml源"> sql性能下降 - 加載60,000 xml文件 - ssis - xml源 </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-biqyvgby-bmt.html" target="_blank" title="openapi v3響應正文中的多行示例"> openapi v3響應正文中的多行示例 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-oepdilmp-bmn.html" target="_blank" title="Python 3.6.3 urlopen從URI中刪除服務器名稱以存儲在遠程服務器上的html文件"> Python 3.6.3 urlopen從URI中刪除服務器名稱以存儲在遠程服務器上的html文件 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-kdthjqxu-bnw.html" target="_blank" title="8位內聯彙編大小不匹配旋轉"> 8位內聯彙編大小不匹配旋轉 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-recklsrc-bnq.html" target="_blank" title="將字符串數組從WWW轉換爲Unity3d中的類列表"> 將字符串數組從WWW轉換爲Unity3d中的類列表 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-heqakphf-bnh.html" target="_blank" title="按鈕上的顏色隨時變化"> 按鈕上的顏色隨時變化 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-tjfkzchb-bcw.html" target="_blank" title="創建簡單的P2P網絡"> 創建簡單的P2P網絡 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-psejxepn-bdc.html" target="_blank" title="添加和更改網頁中的動態內容"> 添加和更改網頁中的動態內容 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-wkacljdr-bdn.html" target="_blank" title="字典分配"> 字典分配 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-ewahdfbq-bgy.html" target="_blank" title="基於彈簧配置文件的彈簧引導應用程序屬性"> 基於彈簧配置文件的彈簧引導應用程序屬性 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-chgwggio-bhu.html" target="_blank" title="NodeJs - 異步/待機異步/等待"> NodeJs - 異步/待機異步/等待 </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-mkuwlotx-yv.html" target="_blank" title="在插入大塊數據後Sql Express上的性能下降"> 在插入大塊數據後Sql Express上的性能下降 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-hdkkuzpg-bac.html" target="_blank" title="大索引插入性能下降(MYSQL)"> 大索引插入性能下降(MYSQL) </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-kmtasxmd-bbh.html" target="_blank" title="Sql查詢性能下降"> Sql查詢性能下降 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-suallqnk-xg.html" target="_blank" title="elasticsearch查詢性能下降"> elasticsearch查詢性能下降 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-pkgunfyc-hw.html" target="_blank" title="Elasticsearch在源域中對大量數據檢索性能下降"> Elasticsearch在源域中對大量數據檢索性能下降 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-edwdkiot-kw.html" target="_blank" title="XML解析:將XML數據插入到數據庫中:性能"> XML解析:將XML數據插入到數據庫中:性能 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-rfsxpnft-gz.html" target="_blank" title="LINQ查詢中的性能下降"> LINQ查詢中的性能下降 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-nolhmory-bho.html" target="_blank" title="數據清除後MySQL數據庫性能下降"> 數據清除後MySQL數據庫性能下降 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-vicarfad-wt.html" target="_blank" title="BlackBerry數據庫性能下降"> BlackBerry數據庫性能下降 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-apnfcizi-ho.html" target="_blank" title="讀取大型XML文件並將數據插入數據庫"> 讀取大型XML文件並將數據插入數據庫 </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>