Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

Why I should not use DataTable.Select() for larger set of records

Reason : Performance degrade
How      : Select() takes arbitary criteria, returns an array of DataRows (Row Collection).  It has to walk thru the entire table and compare every record to the criteria that you passed in. It is
considered worst method to use for large set of records.

So here is the alternative,

1) DataTable.Rows.Find if you look for single row…
2) Indexing the DataTable..but need to build Index in .NET Code as well.
3) LINQ – recommended
4) Morphing the DataTable into a generic collection like Dictionary(Of String, String) to hold the same data as the DataTable.

Src : Scaling ADO.NET DataTables and Best Practices for Using ADO.NET

Advertisements

May 6, 2009 - Posted by | .NET General

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: