DataSet-Optimization?
Reply
![]() |
|
|
From:
Anand Kumar
|
Hi group,
Here is my thought...
Actually the DataSet is a very complex object .It internal implements other child class like DataRow,DataColumn etc.Serialization of DataSet is expensive and it serialized as XML even if you use the binary formatter. This means that the output stream is not compact. You should consider lot of technique to improve the serialization such as
DataSet objDataset = new DataSet("Customers"); SqlDataAdapter myAdapter = new SqlDataAdapter("Select CustomerId as C,CompanyName as D,ContactName as E,ContactTitle as F from Customers",myConnection); myAdapter.Fill(objDataset); Stream serializationStream = new MemoryStream(byteData,0,byteData.Length,true,true); serializationStream.Position=0; iBinForm.Serialize(serializationStream,objDataset)
Try to avoid the multiple copy of data ,When ever you make changes the data DataSet internally maintain two version of the same data such as original data and change value data. Before making the data serialization just reset the internal buffer as below
// load some data into the dataset customers.Fill(northwind, "Customers"); orders.Fill(northwind, "Orders"); // ... modify the data northwind.AcceptChanges(); // accept the changes made and flush the internal buffers // ... serialize the dataset
Try to identify the DataTable which does not need to be serialize and eliminate this while serialize the DataSet as below
customers.Fill(northwind, "Customers"); orders.Fill(northwind, "Orders"); //� use or modify some data DataSet subset = new DataSet(); // copy just the customer DataTable subset.Tables.Add( northwind.Tables["customers"].Copy()); // ... serialize the subset DataSet
Finally implement your custom class to hold the data of DataSet and serialize this class instead of DataSet because the DataSet by default serialize as XML but your custom class can serialize as binary format.
cheers Anand http://spaces.msn.com/members/anandkumar |
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|