HighTechTalks DotNet Forums  

Loading Large XML

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Loading Large XML in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Debasish Pramanik
 
Posts: n/a

Default Loading Large XML - 11-29-2007 , 07:23 AM






We do a FOR XML query using SQLXMLReader.ExecuteXMLReader() method. The
results is obtained in a XMLReader. We then load XMlDocument using XmlReader
as we have to process the XML.

When we try to fire a query which returns huge data, the query executed by
database is 6 seconds but to load the XML it takes 30 minutes. It could be
30-50 MB xml.

Is there any better way to load the XML.

Reply With Quote
  #2  
Old   
Andrew Brook
 
Posts: n/a

Default Re: Loading Large XML - 11-29-2007 , 08:54 AM






Hiya,

When you say it took 6 seconds for the query to complete, are you sure it's
actually completed? Even though the reader starts returning data, i'm fairly
sure this does not mean all the data for the query has been full prepared.
If i'm not talking garbage, it could mean that your query is actually taking
30 minutes to fully complete, in which case, optimizing your query may be
better then changing the way you load your xml

Andrew

"Debasish Pramanik" <Debasish Pramanik (AT) discussions (DOT) microsoft.com> wrote in
message news:994F1554-46DF-47C5-AE32-839334B002F2 (AT) microsoft (DOT) com...
Quote:
We do a FOR XML query using SQLXMLReader.ExecuteXMLReader() method. The
results is obtained in a XMLReader. We then load XMlDocument using
XmlReader
as we have to process the XML.

When we try to fire a query which returns huge data, the query executed
by
database is 6 seconds but to load the XML it takes 30 minutes. It could be
30-50 MB xml.

Is there any better way to load the XML.



Reply With Quote
  #3  
Old   
Debasish Pramanik
 
Posts: n/a

Default Re: Loading Large XML - 11-30-2007 , 12:41 AM



Hi Andrew:

Thanks for quick response.

This is the way I validated.

Step 1: I executed the query with DOM loading. This took almost 30 minutes.
I did this twice and result were same.

Step 2: I then executed only the query without loading the XML. It just took
6 seconds on an average for 10 iteration.

This was the basis of my findings.

Let me just dump the code

String Query = "Select .... FOR XML EXPLICT";

XmlReader reader = sqlXMLReader.ExecuteReader(Query); <== this takes 6 seconds
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader); <==== This takes 30 minutes



"Andrew Brook" wrote:

Quote:
Hiya,

When you say it took 6 seconds for the query to complete, are you sure it's
actually completed? Even though the reader starts returning data, i'm fairly
sure this does not mean all the data for the query has been full prepared.
If i'm not talking garbage, it could mean that your query is actually taking
30 minutes to fully complete, in which case, optimizing your query may be
better then changing the way you load your xml

Andrew

"Debasish Pramanik" <Debasish Pramanik (AT) discussions (DOT) microsoft.com> wrote in
message news:994F1554-46DF-47C5-AE32-839334B002F2 (AT) microsoft (DOT) com...
We do a FOR XML query using SQLXMLReader.ExecuteXMLReader() method. The
results is obtained in a XMLReader. We then load XMlDocument using
XmlReader
as we have to process the XML.

When we try to fire a query which returns huge data, the query executed
by
database is 6 seconds but to load the XML it takes 30 minutes. It could be
30-50 MB xml.

Is there any better way to load the XML.




Reply With Quote
  #4  
Old   
Andrew Brook
 
Posts: n/a

Default Re: Loading Large XML - 12-10-2007 , 06:57 AM



Hi Debasish,

I think this still matches my earlier comment, I think even though your call
to ExecuteReader returns almost immediately, the data is not all available.
I think it's like when you execute a query in the query analyser, some rows
appear quite quickly (depending on the query) but it can take some time
before all the rows are returned.

As a further test, take the DOM out of the equation, try executing the
reader and then interating of the rows that are returned. If i'm right then
it should still take in the region of 30 mins to complete.

Code would be something like:

XmlReader reader = sqlXMLReader.ExecuteReader(Query);
int count = 0;
while (reader.read())
{
count ++;
}

thanks,
Andrew

"Debasish Pramanik" <Debasish Pramanik (AT) discussions (DOT) microsoft.com> wrote in
message news:207B5E5C-0D2B-4DBC-B895-97EB25E43758 (AT) microsoft (DOT) com...
Quote:
Hi Andrew:

Thanks for quick response.

This is the way I validated.

Step 1: I executed the query with DOM loading. This took almost 30
minutes.
I did this twice and result were same.

Step 2: I then executed only the query without loading the XML. It just
took
6 seconds on an average for 10 iteration.

This was the basis of my findings.

Let me just dump the code

String Query = "Select .... FOR XML EXPLICT";

XmlReader reader = sqlXMLReader.ExecuteReader(Query); <== this takes 6
seconds
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader); <==== This takes 30 minutes



"Andrew Brook" wrote:

Hiya,

When you say it took 6 seconds for the query to complete, are you sure
it's
actually completed? Even though the reader starts returning data, i'm
fairly
sure this does not mean all the data for the query has been full
prepared.
If i'm not talking garbage, it could mean that your query is actually
taking
30 minutes to fully complete, in which case, optimizing your query may be
better then changing the way you load your xml

Andrew

"Debasish Pramanik" <Debasish Pramanik (AT) discussions (DOT) microsoft.com> wrote
in
message news:994F1554-46DF-47C5-AE32-839334B002F2 (AT) microsoft (DOT) com...
We do a FOR XML query using SQLXMLReader.ExecuteXMLReader() method. The
results is obtained in a XMLReader. We then load XMlDocument using
XmlReader
as we have to process the XML.

When we try to fire a query which returns huge data, the query
executed
by
database is 6 seconds but to load the XML it takes 30 minutes. It could
be
30-50 MB xml.

Is there any better way to load the XML.






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.