Skip to content

Commit

Permalink
Delegating command preparation to the driver (#8) (#3297)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored and NateBrady23 committed Feb 19, 2018
1 parent bb7c02d commit 14ad208
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/Benchmarks/Data/DapperDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public async Task<World> LoadSingleQueryRow()
}
}

async Task<World> ReadSingleRow(DbConnection db)
Task<World> ReadSingleRow(DbConnection db)
{
return await db.QueryFirstOrDefaultAsync<World>(
return db.QueryFirstOrDefaultAsync<World>(
"SELECT id, randomnumber FROM world WHERE id = @Id",
new { Id = _random.Next(1, 10001) });
}
Expand Down
8 changes: 0 additions & 8 deletions frameworks/CSharp/aspnetcore/Benchmarks/Data/RawDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ DbCommand CreateReadCommand(DbConnection connection)
id.Value = _random.Next(1, 10001);
cmd.Parameters.Add(id);

// Prepared statements improve PostgreSQL performance by 10-15%
// Especially if you only call them once, instead of on every execution :)
cmd.Prepare();

return cmd;
}

Expand Down Expand Up @@ -135,7 +131,6 @@ public async Task<World[]> LoadMultipleUpdatesRows(int count)
}

updateCmd.CommandText = updateCommand.ToString();
updateCmd.Prepare();
await updateCmd.ExecuteNonQueryAsync();
}
}
Expand All @@ -155,9 +150,6 @@ public async Task<IEnumerable<Fortune>> LoadFortunesRows()
db.ConnectionString = _connectionString;
await db.OpenAsync();

// Prepared statements improve PostgreSQL performance by 10-15%
cmd.Prepare();

using (var rdr = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection))
{
while (await rdr.ReadAsync())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ConnectionString": "Server={db_server_placeholder};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;NoResetOnClose=true",
"ConnectionString": "Server={db_server_placeholder};Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;NoResetOnClose=true;Max Auto Prepare=3",
"Database": "postgresql"
}

0 comments on commit 14ad208

Please sign in to comment.