MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:July 28 2010 8:57pm
Subject:bzr commit into connector-net-6.0 branch (vvaintroub:829) Bug#55609
View as plain text  
#At file:///H:/connector_net/6.0/ based on revid:vvaintroub@stripped

  829 Vladislav Vaintroub	2010-07-28
      Fix DataAdapter.Update() slowdown due to many 
      superfluous DataTable.AcceptChanges() calls
      (Bug #55609)

    modified:
      MySql.Data/Provider/Source/dataadapter.cs
=== modified file 'MySql.Data/Provider/Source/dataadapter.cs'
--- a/MySql.Data/Provider/Source/dataadapter.cs	2010-07-12 14:38:02 +0000
+++ b/MySql.Data/Provider/Source/dataadapter.cs	2010-07-28 20:57:47 +0000
@@ -169,9 +169,21 @@ namespace MySql.Data.MySqlClient
 
             try
             {
+                Dictionary<DataTable, bool> modifiedTables = new Dictionary<DataTable, bool>();
+
+                // Scan rows, lookiing for modified tables, we'll use them later 
+                // for AcceptChanges().
+                //
+                // Also open connections for insert/update/update commands, if 
+                // connections are closed.
                 foreach(DataRow row in dataRows)
                 {
                     OpenConnectionIfClosed(row.RowState, connectionsOpened);
+                    if (row.RowState != DataRowState.Unchanged &&
+                        row.RowState != DataRowState.Detached)
+                    {
+                        modifiedTables[row.Table] = true;
+                    }
                 }
 
                 int ret = base.Update(dataRows, tableMapping);
@@ -180,10 +192,10 @@ namespace MySql.Data.MySqlClient
                 // (even if  documentation states otherwise).
                 // Do AcceptsChanges() here, for SQL Server compatible behavior
                 // (see also Bug#5463)
-                foreach (DataRow row in dataRows)
-                {
-                    row.Table.AcceptChanges();
-                }
+                
+                foreach (DataTable table in modifiedTables.Keys)
+                    table.AcceptChanges();
+
                 return ret;
 
             }
@@ -195,6 +207,7 @@ namespace MySql.Data.MySqlClient
 
         }
 
+
         #region Batching Support
 
         public override int UpdateBatchSize


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20100728205747-1y5kqg0lrjxetj5k.bundle
Thread
bzr commit into connector-net-6.0 branch (vvaintroub:829) Bug#55609Vladislav Vaintroub28 Jul