Fastest Method to add rows to a dataset?

  • Thread starter Thread starter Leon_Amirreza
  • Start date Start date
L

Leon_Amirreza

Hi,
I need to add thousands of rows to a Dataset:

1- I have heard that some mechanism like EnforceConstraints = false would
make it Faster;
any more options on the Dataset to make it even faster?

2- the Dataset is bound to SOME BindingSources that they are also bound to
many components on the form (simple and complex);
any other options on the BindingSources to make it even faster?

3- Even more options?

Thank you very much
 
Why?

Serious question. Why are you adding 1000s of rows to a DataSet? Is this for
display purposes (report) or so you can add them to the database? If the
latter, I suggest not using the DataSet, as it is not the best way to bulk
load records.

If for a Report, you probably have the option of linking hte two persistant
stores to get one DataSet. Just a thought.

Back to why? Answers to the question of which is faster are meaningless
until one understands the context.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
Because I have a DataGenerator (or whatever u want to call it) = some kind
of math or simulation program
that produces data in a FOR statement i need somewhere to store it in memory
(no backing store at all)
I have 4 Gb Ram to store temporary data (no problem with that)
But i want to bowse the result (output) at one see if it is usable then
persist it or in other words store it in a file!
 
If speeding up view time for your test data is your goal, then here are some
options.

For speeding up a DataSet, you end up turning off all constraints, which it
sounds like you have already hit apon. I am not 100% sure the best way to
turn off all type checking, other than perhaps make everything a string.
There is a danger in going that direction, however, as you have no type
checking if you approve the test data.

I do not know of any other way to speed things up tremendously with
DataSets. Other directions to try are LINQ and the EntityFramework. I can
tell you, from experience, that LINQ may load faster, but it will certainly
bog down on putting thousands of rows into the database. It also requires an
open context the entire time, which may or may not be a no go for you. The
EntityFramework is promising, but I have not played with it for this type of
work.

One other option is to create custom objects that you load and then your
biggest worry is putting them into the database. You can load them back into
a dataset and perhaps put up with the slowness at that point (already
approved data) or you can set up a DAL of your own. You might also choose to
bulk load from the objects at this point.

For speed, I you might also consider putting up a temp table and creating a
bulk load file. This is likely to have low impact on your current design.
You can then examine the contents from the database rather quickly or
migrate directly into the main table from there. Creating the file should
take a second or two at max, bulk loading a few thousand rows is very fast
as well. Not sure on load of the DataSet from the database, but that should
be fairly fast.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
Back
Top