我使用下面的查询来返回MarkLogic服务器中每个数据库的大小。查询返回数据但不确定查询返回的单位(KB / MB / GB等)。我试图手动找到每个集合的大致大小,但不知何故,这些数字不匹配。 MarkLogic默认是否对文档应用压缩?
xquery version "1.0-ml";
declare namespace forest = "http://marklogic.com/xdmp/status/forest";
for $db-id in xdmp:databases()
let $db-name := xdmp:database-name($db-id)
let $db-size :=
fn:sum(
for $f-id in xdmp:database-forests($db-id)
let $f-status := xdmp:forest-status($f-id)
let $space := $f-status/forest:device-space
let $f-name := $f-status/forest:forest-name
let $f-size :=
fn:sum(
for $stand in $f-status/forest:stands/forest:stand
let $stand-size := $stand/forest:disk-size/fn:data(.)
return $stand-size
)
return $f-size
)
order by $db-size descending
return $db-name || " = " || $db-size
“群集状态”页面上管理界面中显示的单位度量始终为MB,其中显示的数字与您的代码返回的数字相匹配。
MarkLogic并不真正应用压缩,但它确实具有复杂的逻辑来获取数据,并为每个文档分离信息。当您在文档中重复时,会有一些好处。重复次数越多,差异越大,也包括元素名称。
HTH!