Home
> Uncategorized > 300% performance increase on #MySQL inserts in C#
300% performance increase on #MySQL inserts in C#

This may be obvious to anybody who frequently uses MySQL in C#, but for someone who’s come from the SQL Server world, you may quickly realise that the connection pool management is not done as well in MySQL as it is in SQL Server. I guess it is something lacking in the MySQL connector.
Anyway, long story short – if your code for inserts in mysql is as follows (pseudocode:)
Foreach(item in collection)
{
Open Connection
Run SQL
Close Connection
}
Then you can have a huge (300%) performance increase by doing the following:
Open Connection
Foreach (item in collection)
{
Run SQL
}
Close Connection
It’s pretty obvious, but you don’t have to do this sort of refactoring with the SQL Server driver, since the connection pool is managed under-the-hood.
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback