Search code examples
jsonxmlmarklogicmarklogic-10

Does MarkLogic store JSON natively?


I was exploring how size in ML DB increases when we used XML data model and JSON data model. I found that the JSON files are taking more space than XML documents.

Below are the steps of this experiment -

  1. Select a XML document of your choice and create a JSON of the same XML.
  2. Create two fresh databases for each type of documents i.e. one DB will hold XML documents and another will hold JSON documents.
  3. Insert both files in corresponding databases and find the binary size of each using script mentioned in this https://developer.marklogic.com/recipe/document-size/ link.
  4. Then create a simple xquery to insert the JSON file multiple times with different uri in DB for JSON, create similar script for XML and insert in DB for XML.

I inserted 1 Million copies of each documents and found that the size of XML DB was 250 MB less than the JSON DB. One more thing the size of JSON document was ~13.3 KB and that of XML document was ~15.6 KB.

Despite the JSON file is smaller, but its 1M copies took 250 MB more.

Is MarkLogic saving the JSON natively? Why the size of JSON files to more space?


Solution

  • Yes, MarkLogic saves JSON natively.

    I'm not surprised that XML compresses better than JSON, because the plain serialized format is so verbose.