[MarkLogic Dev General] Size of xml and binary documents

David Lee David.Lee at marklogic.com
Tue Aug 14 06:08:00 PDT 2012

For XML documents the size is not defined exactly.  What is stored on disk is not the text serialized form, and there are multiple serialized forms for an XML document.
You can retrieve the document and convert it to a string like

    fn:string-length( xs:string(doc("file.xml")))

That should give you something close but is a heavy operation (requires fetching and serializing the document) and may or may not be the same size as when you really extract and store the document.

For binary documents see:


But like XML documents you  need to extract the document to calculate its size.

Another proposition is to store as a document property the size ... again, for XML this size is not a constant but a function of the serialization used.

David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 650-287-2531
Cell:  +1 812-630-7622

This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation.

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Danny Sinang
Sent: Tuesday, August 14, 2012 9:03 AM
To: general
Subject: [MarkLogic Dev General] Size of xml and binary documents


In ML 4.2, how do you get the size of both xml and binary documents ?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120814/e46307af/attachment.html 

More information about the General mailing list