[xquery-talk] Matrix Multiplication (JSONiq)

Michael Kay mike at saxonica.com
Sun Feb 2 13:13:46 PST 2014

On 2 Feb 2014, at 20:33, jean-marc Mercier <jeanmarc.mercier at gmail.com> wrote:

> N-dimensional representation of arrays are quite straightforward with XML too. Is there any incentive to expect better performances with a JSON matrix representation rather than an XML one ?

I think that if you had an XML schema for an XML representation of N-dimensional arrays, and if the XPath processor recognized that schema and used a custom tree representation for its instances, then arrays could be represented using XML just as efficiently as using JSONiq arrays. But if you use a general tree representation that allow any element names, namespaces, base URIs, mixed content, attributes, and all the other paraphernalia of XML, then it is likely to be significantly less efficient. 

For example:

* XML is text-oriented, and using XML for numeric values invariably involves string-to-number conversion, which is expensive

* Numeric subscripts when addressing XML (as in para[3]) are likely to have O(n) performance rather than constant performance, because the tree structure is likely to be optimized for scanning all the children rather than locating an individual child by its index.

Michael Kay

More information about the talk mailing list