I have tried to councel against sending datasets across web service calls, but we have a lot of instances where this is being done.
One of the problems with this is that datasets get bloated when converted to XML.
So I set out to compare the sizes of:
- Serialized List(Of MyType)
- Serialized DataTable
- Serialized DataSet
- XML Serialized Dataset
I wish I had done some research on this, because I would have quickly been reminded that DataSets always serialize as XML, even if you are using the BinaryFormatter.
There are lots of people out there coming up with their own ideas for how to improve the serialization of datasets:
Anyway, this isn’t really THAT big of a deal, because my real goal wasn’t to improve the dataset serialization, but to simply see what it would be, and compare it to some other ways to serialize data, like in a list of business objects or a datatable.
The results are interesting:
Given a list of 1013 Business Objects (Records) the serialization results are as follows:
Method |
Size (bytes) |
List(Of MyType) |
290,321 |
DataTable |
819,575 |
DataSet |
693,088 |
XML Serialzied Dataset |
851,614 |
I have read that you can really decrease the size of the dataset by writing your own logic to do the serialization, but as everyone points out that is kind of a pain.