From 774040e9d7d1cd9936c4a2435c770de6942c1a20 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 21 Sep 2017 18:15:51 +1000 Subject: [PATCH] Just use count(id) for /sinfo on both backend, closes #255 In the test SQLite database with 800,000 players there was a 2-3 millisecond difference. So not worth it. --- MCGalaxy/Commands/Information/CmdServerInfo.cs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/MCGalaxy/Commands/Information/CmdServerInfo.cs b/MCGalaxy/Commands/Information/CmdServerInfo.cs index aafc18d80..2b66b79ed 100644 --- a/MCGalaxy/Commands/Information/CmdServerInfo.cs +++ b/MCGalaxy/Commands/Information/CmdServerInfo.cs @@ -62,21 +62,9 @@ namespace MCGalaxy.Commands.Info { } static int GetPlayerCount() { - // Use fast path if possible TODO: fast path for mysql - int count = 0; - if (!ServerConfig.UseMySQL) { - DataTable maxTable = Database.Backend.GetRows("Players", "MAX(_ROWID_)", "LIMIT 1"); - if (maxTable.Rows.Count > 0) { - string row = maxTable.Rows[0]["MAX(_ROWID_)"].ToString(); - maxTable.Dispose(); - if (int.TryParse(row, out count) && count > 0) return count; - } + using (DataTable table = Database.Backend.GetRows("Players", "COUNT(id)")) { + return int.Parse(table.Rows[0]["COUNT(id)"].ToString()); } - - DataTable table = Database.Backend.GetRows("Players", "COUNT(id)"); - count = int.Parse(table.Rows[0]["COUNT(id)"].ToString()); - table.Dispose(); - return count; } void ShowServerStats(Player p) {