mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 17:18:40 +01:00
Optimized server player list table query
Original benchmark: 4 seconds Improved benchmark: 500 milliseconds -> 8x faster
This commit is contained in:
parent
1b0942c988
commit
987fb7b56a
@ -76,10 +76,9 @@ public class ExtensionServerTableDataQuery implements Query<Map<UUID, ExtensionT
|
||||
|
||||
private Query<Map<UUID, ExtensionTabData>> fetchPlayerData() {
|
||||
String selectLimitedNumberOfPlayerUUIDsByLastSeenDate = SELECT +
|
||||
UsersTable.USER_UUID + ",MAX(" + SessionsTable.SESSION_END + ") as last_seen" +
|
||||
SessionsTable.USER_ID + ",MAX(" + SessionsTable.SESSION_END + ") as last_seen" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " u on u." + UsersTable.ID + '=' + SessionsTable.TABLE_NAME + '.' + SessionsTable.USER_ID +
|
||||
GROUP_BY + UsersTable.USER_UUID +
|
||||
GROUP_BY + SessionsTable.USER_ID +
|
||||
ORDER_BY + "last_seen DESC LIMIT ?";
|
||||
|
||||
String sql = SELECT +
|
||||
@ -98,7 +97,8 @@ public class ExtensionServerTableDataQuery implements Query<Map<UUID, ExtensionT
|
||||
"i1." + ExtensionIconTable.ICON_NAME + " as provider_icon_name," +
|
||||
"i1." + ExtensionIconTable.FAMILY + " as provider_icon_family" +
|
||||
FROM + ExtensionPlayerValueTable.TABLE_NAME + " v1" +
|
||||
INNER_JOIN + '(' + selectLimitedNumberOfPlayerUUIDsByLastSeenDate + ") as last_seen_q on last_seen_q.uuid=v1." + ExtensionPlayerValueTable.USER_UUID +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " u on u." + UsersTable.USER_UUID + "=v1." + ExtensionPlayerValueTable.USER_UUID +
|
||||
INNER_JOIN + '(' + selectLimitedNumberOfPlayerUUIDsByLastSeenDate + ") as last_seen_q on last_seen_q.user_id=u." + UsersTable.ID +
|
||||
INNER_JOIN + ExtensionProviderTable.TABLE_NAME + " p1 on p1." + ExtensionProviderTable.ID + "=v1." + ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
INNER_JOIN + ExtensionPluginTable.TABLE_NAME + " e1 on e1." + ExtensionPluginTable.ID + "=p1." + ExtensionProviderTable.PLUGIN_ID +
|
||||
LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i1 on i1." + ExtensionIconTable.ID + "=p1." + ExtensionProviderTable.ICON_ID +
|
||||
@ -124,11 +124,10 @@ public class ExtensionServerTableDataQuery implements Query<Map<UUID, ExtensionT
|
||||
|
||||
private Query<Map<UUID, ExtensionTabData>> fetchPlayerGroups() {
|
||||
String selectLimitedNumberOfPlayerUUIDsByLastSeenDate = SELECT +
|
||||
UsersTable.USER_UUID + "," +
|
||||
SessionsTable.USER_ID + "," +
|
||||
"MAX(" + SessionsTable.SESSION_END + ") as last_seen" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " u on u." + UsersTable.ID + '=' + SessionsTable.TABLE_NAME + '.' + SessionsTable.USER_ID +
|
||||
GROUP_BY + UsersTable.USER_UUID +
|
||||
GROUP_BY + SessionsTable.USER_ID +
|
||||
ORDER_BY + "last_seen DESC LIMIT ?";
|
||||
|
||||
String sql = SELECT +
|
||||
@ -139,7 +138,8 @@ public class ExtensionServerTableDataQuery implements Query<Map<UUID, ExtensionT
|
||||
"i1." + ExtensionIconTable.ICON_NAME + " as provider_icon_name," +
|
||||
"i1." + ExtensionIconTable.FAMILY + " as provider_icon_family" +
|
||||
FROM + ExtensionGroupsTable.TABLE_NAME + " v1" +
|
||||
INNER_JOIN + '(' + selectLimitedNumberOfPlayerUUIDsByLastSeenDate + ") as last_seen_q on last_seen_q.uuid=v1." + ExtensionGroupsTable.USER_UUID +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " u on u." + UsersTable.USER_UUID + "=v1." + ExtensionGroupsTable.USER_UUID +
|
||||
INNER_JOIN + '(' + selectLimitedNumberOfPlayerUUIDsByLastSeenDate + ") as last_seen_q on last_seen_q.user_id=u." + UsersTable.ID +
|
||||
INNER_JOIN + ExtensionProviderTable.TABLE_NAME + " p1 on p1." + ExtensionProviderTable.ID + "=v1." + ExtensionGroupsTable.PROVIDER_ID +
|
||||
INNER_JOIN + ExtensionPluginTable.TABLE_NAME + " e1 on e1." + ExtensionPluginTable.ID + "=p1." + ExtensionProviderTable.PLUGIN_ID +
|
||||
LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i1 on i1." + ExtensionIconTable.ID + "=p1." + ExtensionProviderTable.ICON_ID +
|
||||
|
Loading…
Reference in New Issue
Block a user