views:

372

answers:

3

I have the option of storing data in memory either as an XML document or multi-table ADO dataset. The web page utilizing this object will be selectively retrieving data items based on keys.

Does either of these objects have a clear performance advantage over the other?

A: 

Hi, A DataSet is already an XML Document, sort of. One of the additional perks you get with the dataset is relationship between tables, so you can actually query the DataSet as an in-memory database.

XML is really good, especially in certain situations, but searching lots of data.

If it's items based on keys with no relation to other tables then go with the XML, but be careful with large subsets of data.

Saif Khan
As far as I remember a DataSet isn't XML until it's serialised.
Kev
A: 

Picking up on what Saif said, your biggest challenge with XML will be relating keys from one document to the other. You can create unique keys for all the nodes in the document, but you may have improper collisions should you have another document of similar structure as the documents are distinct. In other words, you would have to ensure that there was no overlap by either merging documents temporarily or creating another scheme that concatenates additional identifiers to the dynamically generated keys.

Depending on your comfort level with XPath and XLST, you may want to create tables and relations with ADO, as this is more straight forward. You can do grouping of keys, and Jeni Tennison who posts at StackOverflow has a great series on these methods.

David Robbins
+2  A: 

If you decide to go down the XML route and if you're using .NET 3.5 consider looking at the new XDocument, XElement (and friends) classes in the System.Xml.Linq namespace. You can use Linq to XML to query your XML documents and it's rather good.

Kev