M
Markus Hjärne
Thanks for the reference,
but I couldn't see anything there about increased Remove performance. I
don't have any index on the DataTable in my test code, so I'm not sure it
will make any difference with the re-written indexing engine. And also,
another post in this thread mentions that Remove is still slow in .NET 2
beta.
Regards,
Markus
but I couldn't see anything there about increased Remove performance. I
don't have any index on the DataTable in my test code, so I'm not sure it
will make any difference with the re-written indexing engine. And also,
another post in this thread mentions that Remove is still slow in .NET 2
beta.
Regards,
Markus
Deepak said:Hi Markus,
This is the source of my information on DataTable Indexing engine for
ADO.NET 2.0
http://msdn.microsoft.com/data/default.aspx?pull=/library/en-us/dnadonet/html/datasetenhance.asp
Regards,
Deepak
[I Code, therefore I am]
Markus Hjärne said:Thanks for yor reply,
can you tell me what's your source of information when you say that the
indexing engine has been re-written i ADO.NET 2.0?
Regards,
Markus
thusDeepak said:Indexing engine for DataTable in ADO.NET 1.x is not very optimized,
youthatfacing this issue.
It has been re-written in ADO.NET 2.0, and will do these operations much
faster. I believe there is nothing much you can do about this. Storing your
data in multiple data tables will boost performance, but you will have to
access this based on your requirements.
--
Regards,
Deepak
[I Code, therefore I am]
I'm using a DataTable to hold a selection of rows (100,000+) from a large
database table (1,000,000+ rows). At times I want to remove rows that
aren't
used anymore from the DataTable to save memory. But my tests shows
itwaytakes very long time to remove the rows. Running the code below on a
Pentium
2.4 Ghz under Windows XP reports that it takes 187ms to add 100,000 rows,
but 32s (seconds, that is!) to remove half of them.
Can anybody tell me what I'm doing wrong or an alternative, faster
toelapseddo
this?
// Create table with one int column
DataTable table = new DataTable();
table.Columns.Add(
new DataColumn(
"Col1",
typeof(int)
)
);
// Add a number of rows to the table
int ticks = Environment.TickCount;
for (int i = 0; i < 100000; i++)
{
table.Rows.Add(new object[] {i});
}
int elapsed = Environment.TickCount - ticks;
MessageBox.Show("Added " + table.Rows.Count + " rows in " + elapsed + "
ms.");
// Create a list of rows to remove (half of those in table)
ArrayList rowsToRemove = new ArrayList(table.Rows.Count/2);
for (int i = 0; i < table.Rows.Count; i++)
{
if ((i % 2) == 0)
rowsToRemove.Add(table.Rows);
}
// Remove the rows from the table
ticks = Environment.TickCount;
for (int i = 0; i < rowsToRemove.Count; i++)
{
table.Rows.Remove((DataRow)rowsToRemove);
}
elapsed = Environment.TickCount - ticks;
MessageBox.Show("Removed " + rowsToRemove.Count + " rows in " +
+"
ms.");
Grateful for any help on this,
Markus Hjarne