mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -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,23 +62,11 @@ namespace MCGalaxy.Commands.Info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int GetPlayerCount() {
|
static int GetPlayerCount() {
|
||||||
// Use fast path if possible TODO: fast path for mysql
|
using (DataTable table = Database.Backend.GetRows("Players", "COUNT(id)")) {
|
||||||
int count = 0;
|
return int.Parse(table.Rows[0]["COUNT(id)"].ToString());
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
void ShowServerStats(Player p) {
|
||||||
Process proc = Process.GetCurrentProcess();
|
Process proc = Process.GetCurrentProcess();
|
||||||
if (allPCounter == null) {
|
if (allPCounter == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user