我有一个很大的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