ModdedMinecraftClub/Mmcc.Stats

Abysmal performance of Dapper in SelectPingsByDateAsync despite highly performant SQL query

Closed this issue · 1 comments

QueryAsync<T> with the following SQL which is inside SelectPingsByDateAsync takes 4s to complete when run against the whole dataset despite taking only 0.33s in MySQL console with the same parameters.

SELECT server.serverId, server.serverName, pings.pingTime, pings.playersOnline
FROM pings
INNER JOIN server ON pings.serverId = server.serverId
WHERE pingTime >= @fromDate and pingTime <= @toDate
ORDER BY pings.pingTime;

Method in question:

public async Task<IEnumerable<ServerPingDto>> SelectPingsByDateAsync(DateTime fromDate, DateTime toDate)

Nvm, it's just MySQL being MySQL. I did my best - switched the driver from MySql.Data to MySqlConnector which shaved off a second. Switching over to Postgres would fix the issue permanently (0.8-0.9s vs 4s with MySQL) but unfortunately John == MySQL/PHP cultist.

My work here is done.