Wednesday, March 21, 2012

saving a collection of objects to a table

Hello all,
Is there a more efficient way to save a collection of custom objects to a sql server database, other then calling a stored procedure in a loop for each object in the collection?
Any suggestions on how to make this as efficient as possible are welcome.What is the nature of the objects?

If the objects can be serialized to XML then storing the collection as an XML string should work well.|||Actually this is the funny part,
The collection is a result of an xml parsing function. Due to the cost of xml parsing i'm saving
the parse result to a database.
Maybe you could advise on general program design here. I'm very new to the xml thing
and what i need to do is to make a details page of sorts ( which in current form ) at runtime
accesses and parses up to 8 xml files from another server on the network. There is significant
delay between details link click and the actual details page coming up due to the processing taking place behind the scenes, hence my decision to parse once and respond to the subsequent calls with results from the database. The processing involves a number of loops since it is the only logical way i can think of to parse the xml. The only way to parse the xml doc is to
basically loop thourgh it and get what you want am i correct?
Maybe you have and idea for a better quicker design?
thank you for response.|||XML is a good means for exchanging data but as you've seen not necessarily a great means for storing data for quick retrieval. It sounds like parsing once and storing the relevant results into a database for easier retrieval is a good strategy. I've seen sites use this approach for the same reasons you've encountered. (One company's engineers had to "hide" this fact because there was a design dictum to use XML for everything.)

I'm not an expert in XML parsing and ways to improve parsing performance. There's probably a .Net forum for that. I've always tried to keep my XML as straightforward as possible and use it only when a better/faster alternative isn't available.|||ok thanks. I'll just keep plucking along the current path.|||why not parse once and then cache the collection in memory?

this will give even more benefits than accessing a database.|||That would be fine except we're talking lots and lots of items here (more then 15,000) with
up to 7 xml files for each. Do you think it'd still work or would
the server crap out?

No comments:

Post a Comment