Browse Source

Improve ASP.NET Ado performance 15-30% by removing CommandBehavior.SingleRow

This isn't necessary because we know that only one row will be returned
and it causes the MySql provider to send two extra commands per query.
This didn't seem to change the PostgreSQL performance.

The ado/mysql test improved about 15% and the ado/mysql/update test
improved about 30%.
Malcolm Evershed 12 years ago
parent
commit
ff523808c8
1 changed files with 6 additions and 2 deletions
  1. 6 2
      aspnet/src/Controllers/AdoController.cs

+ 6 - 2
aspnet/src/Controllers/AdoController.cs

@@ -45,7 +45,9 @@ namespace Benchmarks.AspNet.Controllers
                         command.Parameters.Clear();
                         command.Parameters.Add(parameter);
                         
-                        using (DbDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow))
+                        // Don't use CommandBehavior.SingleRow because that will make the MySql provider
+                        // send two extra commands to limit the result to one row.
+                        using (DbDataReader reader = command.ExecuteReader())
                         {
                             if (reader.Read())
                             {
@@ -124,7 +126,9 @@ namespace Benchmarks.AspNet.Controllers
 
                         World world = null;
 
-                        using (DbDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow))
+                        // Don't use CommandBehavior.SingleRow because that will make the MySql provider
+                        // send two extra commands to limit the result to one row.
+                        using (DbDataReader reader = selectCommand.ExecuteReader())
                         {
                             if (reader.Read())
                             {