mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
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.
This commit is contained in:
parent
79de17943c
commit
774040e9d7
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user