MySQL Performance
-
Some time ago, Bernie decided to remove all the code creating and handling MySqlConnections in their codebase. There is a MySqlHelper class with many static methods available, and it hides all the connection creation and re-use (connection pooling) boiler plate code.
Now comes Johnny and desparately looks at the code:
using (IDisposableMeasuredExecution<MySqlDataReader> tmp = StopWatch.MeasureDisposableFunction( () => Retry<MySqlDataReader>.ExecuteWithRetries( () => MySqlHelper.ExecuteReader(m_ConnectionString, _sql, _parameters.ToArray())) )) { Logger.LogDebug(Name, $"Getting xy data from the database took {tmp.Duration}."); return CreateResultFromDatareader(tmp.Result, param1, param2); }
"Nowhere can I see an open connection!
I suspect that thingy will always open a new connection. What a performance hit to the database!"Arrrgggghhh!
-
@BernieTheBernie actually if one can trust https://dev.mysql.com/doc/connector-net/en/connector-net-connections-pooling.html that MySqlHelper is a class from the api and it does all the magic internally
-
@OloEopia said in MySQL Performance:
@BernieTheBernie actually if one can trust https://dev.mysql.com/doc/connector-net/en/connector-net-connections-pooling.html that MySqlHelper is a class from the api and it does all the magic internally
Exactly. But Johnny wants to write his own code. For better performance, and to avoid an "exception" which he did not specify either...
-
You're measuring the time to get the data reader before you've pulled the data out of it. IIRC it streams data as it becomes available, possibly before your query is complete.
-
@BernieTheBernie uh, I failed at reading comprehension and missed that there are Bernie and Johnny in your post, but at least i didn't fail to rtfm like Johnny did :)