DataTable Merge Performance





5.00/5 (2 votes)
This project measures performance of the DataTable.Merge method.
Introduction
Two DataTables
may be merged with the DataTable.Merge
method. The performance of this method is very slow when the destination table has added rows. It is therefore recommended to call the method DataTable.AcceptChanges
when the destination DataTable
has added rows.
The Solution
- Open the DataTableMerge.vbproj with Visual Studio 2010, build and run it. The following form appears:
- In the textbox "Step" must be given the number of records by which each test is to be incremented.
- In the textbox "Max table size" must be given the total number of records of the last test.
- Press the button "Start". This will run the tests. Each test, times the merge operation of two
DataTables
(tableT2
is merged into tableT1
, in VB.NET:T1.Merge(T2)
). 4 combinations are tested:T1UnchangedT2Unchanged
: On both tables, the methodAcceptChanges
has been called.T1UnchangedT2Added
: On tableT1
, the methodAcceptChanges
has been called, records of tableT2
are inRowState=Added
.T1AddedT2Unchanged
: Records of tableT1
are inRowState=Added
, on tableT2
the methodAcceptChanges
has been called.T1AddedT2Added
: Records of tablesT1
andT2
are inRowState=Added
.
The third case (
T1AddedT2Unchanged
) is very slow, for 10000 records, it takes more than 2 minutes. All other cases seem to perform equally fast.
History
- 28th June, 2013: Initial version