C
C#10mo ago
drake

basic mysql query takes around 170ms to complete

Hey, I'm working on a project that uses MariaDB. Currently I'm using MySqlConnector with Dapper and I just noticed that even a smallest query takes around ~170ms, it doesn't matter if the table has either 4 rows or 16k. I tried with and without Dapper because I thought that maybe dapper's mapping might takes that much time, but even with the simplest example it takes around that time. Can someone please enlighten me whats wrong with it or am I going crazy? In the below example both of the query takes as much time.
var statistics = connection.Query<PlayerStatisticsModel, AccountModel, PlayerStatisticsModel>(
"GetPlayerRaceStatistics",
(statistics, account) => { statistics.Player = account; return statistics; },
new { playerId = 1, mapId = "hAIffTh4fEWGCFeLGdenbw" },
splitOn: "id",
buffered: true,
commandType: System.Data.CommandType.StoredProcedure).ToList();

var statistics = connection.Query("SELECT * FROM `gm_race_playerstat`");
var statistics = connection.Query<PlayerStatisticsModel, AccountModel, PlayerStatisticsModel>(
"GetPlayerRaceStatistics",
(statistics, account) => { statistics.Player = account; return statistics; },
new { playerId = 1, mapId = "hAIffTh4fEWGCFeLGdenbw" },
splitOn: "id",
buffered: true,
commandType: System.Data.CommandType.StoredProcedure).ToList();

var statistics = connection.Query("SELECT * FROM `gm_race_playerstat`");
2 Replies
Omnissiah
Omnissiah10mo ago
you have to do some tests, take the network time and the query time so that you know who has the fault have you tried with a client? (command line, for example)
drake
drakeOP10mo ago
the query takes like 0,2ms to run in command line, also I connect to a localhost server I also created an empty project with .NET 7 to see if I have something messed up in my project or not hmmmm looks like something is up with MariaDB server, it is faster with MySQL database, but one strange thing is that the first Query takes 100-200ms to complete, but after that all the query runs in 1-2ms or so
Want results from more Discord servers?
Add your server