我有一個很大的xml數據庫(30 000個文件,1.3 Go)。此數據庫中的一個文件列出數據庫中存在的所有其他文件。我的目標是「簡單地」檢查列出的所有文件是否存在於數據庫中。但我不能關心文件的名稱,只能處理文檔中的XML代碼。XQuery - 爲BIG數據庫優化查詢
這是類似的東西:
declare variable $root := fn:collection();
declare function local:isValid($fileCode) {
let $fileSearchedIdentCode := $root/dmodule/identity/dmCode
return
$fileCode/@attribute1 = $fileSearchedIdentCode/@attribute1 and
$fileCode/@attribute2 = $fileSearchedIdentCode/@attribute2 and
$fileCode/@attribute3 = $fileSearchedIdentCode/@attribute3
};
<result>
{
for $fileCode in $root/file[identity/@fileType eq 'listOfFiles']/fileContent/fileEntry/fileCode
return
if (local:isValid($fileCode))
then <filePresent>1</filePresent>
else <fileNonPresent>2</fileNonPresent>
}
</result>
上面的代碼運行一個小DATABSE但對於我的,它是需要時間的數量驚人。
SO,我不知道是否有人能幫助我提高,以便在合理的時間來執行它的代碼;)
(我的數據庫被索引)
感謝您的幫助!
Johann
我不能編輯我的帖子:(對不起,不說「你好」 – Johann 2012-02-13 14:30:14
說你好不是自定義的。你能告訴你使用哪個數據庫嗎?使用索引可能需要使用專有擴展,或者優化表達式以匹配內置優化30k文檔並不多,但足以想要使用索引 – grtjn 2012-02-13 14:44:25
我必須在幾個數據庫(baseX,marklogic,oracle db XML和qizx)上創建一個基準測試,目前我使用的是BaseX。 – Johann 2012-02-13 14:48:54