Des petits tests fait cette aprem :

 1000 appels à un INSERT d'un row => 1min26
 1 appel à un INSERT de 1000 rows => 4s

Top.

--- => UPDATE

I'm using since one year the connector (and the preceeding ByteFX one) and I'm quite happy with it. My c# project just use it to connect to the database and I don't use the dataset structure to retrieve tables, etc, but anyway, it works great.

Now, I'm trying to optimize the queries. I made theses benchmark on a distant server, using on .NET connector on a client computer and phpMyAdmin directly on the server.

First test : optimizing insert

- 1000x INSERT of 1 row through .NET connector : 81 s
- 1 INSERT of 1000 rows through .NET connector : 3,54 s
- 1000x INSERT of 1 row through local PMA : 13s
- 1 INSERT of 1000 rows through local PMA : 10s
  • I'm using ";" as a separator for the query so in the .NET connector I use exactly the same code for both query.
  • 1000x INSERT is much more slower than 1 INSERT of 1000 rows. Of course, it's documentated.
  • When I put a error on the first insert for the "1000x INSERT" query, an exception arise after 4s. So it's clearly not a connection issue as the server returns me this error in that time. When I put the error at the end of the query, it took around 80s. So apparently, the server need that time to analyse the query. But, why is PMA so fast compared to .NET connector, the server execute the same query ?

Second test : optimizing update

- 1000x UPDATE of 1 row through .NET connector : 80 s
   (using a lock tables write before, unlock table after)
- 1000x UPDATE of 1 row through PMA : 4s (same query as above)
  • Again I'm using the ";" as a separator for queries and use only one MySqlCommand.ExecuteNonQuery
  • Why 4s against 80s for .NET ?