How efficient datatable is for selecting/inserting/deleting row?

B

babylon

what data structure do datatable use internally for searching, inserting and
deleting a row...
thx!
 
W

William Ryan

If I remember correctly, it's a linked list...but I'm not sure what you are
asking in regard to the title of your post. If you are interested in
performance irrespective of how the DataTable affects a given datasource,
what do you want to compare its performance against? If you want to know
how efficient it is in respect to updating/inserting etc to a database, the
answer is that it doesn't do those on the actual database, the DataAdapter
does it for you. And to that end, the adapter does it row by row (although
from what I hear, Whidbey will support set based updates/inserts/deletes
etc).

Let me know what you want to compare it against and perhaps I can be of more
help.

Cheers,

Bill
 
B

babylon

actually i want to know the performance of using datatable as a local
storage
e.g. i would like to store the information of a group of students which
contains
(studentid, student name, age, birthday, subject A's score, subject B's
score, etc...)
i can construct a "student" object and use a hashtable to store the student
object
but in case i want to retrive all the students who's birthday is within
01jan90 to 01jan91
i have to retrive it manually

on the other hand, i can store the information in a datatable...so that i
can use the 'select' statement to retrive the info easily..

actually i want to know there performance of searching/inserting/deleting a
row in a datatable compared to deleting an object from a hashtable (or other
implementation)

e.g. which is better?
1 - searching (use 'select') in datatable
2 - exhaustive search of each object in a hashtable

thx!
 
W

William Ryan

SELECT is only one way to find things in a DataTable, but that's a side
issue. Anyway, your question is kind of hard to answer for the following
reason. A dataTable my have X columns whereas a hashtable has multiple
constructors and may contain one, two three effective columns. I haven't
ever run direct comparisons, but if you only have a key and a value, I'm 99%
that a HashTable would be faster b/c it's not necessarily comprised of
DataColumns which have many more properties than say in Integer. They both
implement IList, but in instances where you are only dealing with one or two
'columns' hash tables are probably quicker. On the other hand, the number
of items has a huge bearing b/c if you are only dealing with 5 values,
they'll both probably perform faster than you can notice the nuances. A
DataTable is a bad boy and has tons of power, but if you don't need features
like AutoIncrement values, a HashTable would probably be quicker.

Just for the record, how many records are you planning on dealing with? I'd
be glad to run a few comparison and see how profound the differences are.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top