Performance for adding rows and finding rows  
Author Message
orangeblood94





PostPosted: .NET Framework Data Access and Storage, Performance for adding rows and finding rows Top

1. When adding rows to a datatable which has a primary key that is an int, should it matter which method is used to insert a new row For example using an Object[] of parms or using the NewRow() method Specifically, would the object[] method perform boxing and the other would not
2. If you already have a DataView created would it be faster to insert into the dataview instead of the datatable Wouldn't the dataview still have to update the underlying datatable
3. When searching is it faster to use the Dataview.Findrows() method or the Datatable.Find() method, when you are searching on the primary key and the dataview is already created
4. If your primary key is an int, does find do boxing, and therefore would it be better to use a string for the key instead of an int

This is for a real-time stock trading program and therefore every millisecond counts. I will be doing many lookups and changes to the datatables and would like to know what data structure is used underneath.

Thanks in advance.


.NET Development23  
 
 
Matt Neerincx





PostPosted: .NET Framework Data Access and Storage, Performance for adding rows and finding rows Top

For #1 I would expect the array method would be faster simply due to the reduced code paths you have to traverse, but I could be wrong here.

#2. DataTable would be faster since DataView just eventually inserts the data into the DataTable, so it's just extra overhead (row abstraction is how DataView works, it keeps an array of row handles).

#3. Not sure on this one.

#4. Not sure on this one either, however the underlying data will be stored as int so I suspect int would be faster.