By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,780 Members | 1,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,780 IT Pros & Developers. It's quick & easy.

How to speed up the ReadXML?

P: n/a
Hi,

In my C# Windows Form project, I'm testing comparing using the SqlClient
with the ReadXML method.
The ReadXML method will read 2 .xml files, one is 4K, the other one is 3Mb,
both are on my PC's local drive.
However, I found that it takes approximately 9 seconds for the ReadXML
method, while the SqlClient method is about 2 seconds.
Now I have 2 quesitons here:
1. Is it possible to speed up the ReadXML?
2. When will my PC's erase DataSet's ReadXML memory?

Thanks for help.
Jason
Apr 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jason,

ReadXML must parse the entire XML document before it can represent it
in a relational-like format, which uses a lot resources for large
documents. The SqlClient method will always be faster. There are a
number of ways to improve performance with XML data, see
http://msdn.microsoft.com/library/de...netchapt09.asp,
but I'm not sure these recomendations will help ReadXML.

Once your DataSet goes out of scope or you call Dispose() it will be
marked for garbage collection and the memory will be reclaimed.

-Carl

Apr 1 '06 #2

P: n/a
It should be noted that SqlClient will not always be faster than reading
an XML document. It depends on the size of the data, the structure, etc,
etc. Also, you have to consider the other factors in play here, namely, is
it appropriate to store this information in the database as opposed to a
config file which is most likely stored locally?

On top of that, it should be noted that calling Dispose on the DataSet
will not mark it for garbage collection. The Dispose pattern on the DataSet
is inherited from the MarshalByValueComponent class, and the DataSet does
nothing to override that behavior. The only thing that calling Dispose on
the DataSet does is fire the Disposed event.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Carl" <cz******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Jason,

ReadXML must parse the entire XML document before it can represent it
in a relational-like format, which uses a lot resources for large
documents. The SqlClient method will always be faster. There are a
number of ways to improve performance with XML data, see
http://msdn.microsoft.com/library/de...netchapt09.asp,
but I'm not sure these recomendations will help ReadXML.

Once your DataSet goes out of scope or you call Dispose() it will be
marked for garbage collection and the memory will be reclaimed.

-Carl

Apr 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.