Fire Monkey Posted October 13, 2020 Share Posted October 13, 2020 I'm writing an account system. When the player login, sets all the database index and values on the ID player set as a table. To get index of player is received from the table. To set index and value of player, I used query and table again. For example: local data = {} function getData(player, data) local id = playerid[player] if not id then return end return data[id][data] end function setData(player, data, value) local id = playerid[player] if not id then return end data[id][data] = value --query return true end Do you think it is better to set on the ID or on the player? Or does it matter? Link to comment
iPrestege Posted October 14, 2020 Share Posted October 14, 2020 Why don't you just set it on the player instead? And if you want to store it use the player serial to make it more efficient and no one can have more than one record since it's by serial. 1 Link to comment
Fire Monkey Posted October 14, 2020 Author Share Posted October 14, 2020 On 14/10/2020 at 10:08, iPrestege said: Why don't you just set it on the player instead? And if you want to store it use the player serial to make it more efficient and no one can have more than one record since it's by serial. Expand Does using an ID or player make a difference in improving performance? Link to comment
Scripting Moderators xLive Posted October 15, 2020 Scripting Moderators Share Posted October 15, 2020 On 14/10/2020 at 19:50, Fire Monkey said: Does using an ID or player make a difference in improving performance? Expand No, but I suggest to to use the player element you don't need to use another function to get the serial or id just pass the player Link to comment
Fire Monkey Posted October 15, 2020 Author Share Posted October 15, 2020 On 15/10/2020 at 06:21, xLive said: No, but I suggest to to use the player element you don't need to use another function to get the serial or id just pass the player Expand Element do not look optimized. Especially if there are more players. Link to comment
Moderators IIYAMA Posted October 17, 2020 Moderators Share Posted October 17, 2020 (edited) On 15/10/2020 at 14:26, Fire Monkey said: Element do not look optimized. Especially if there are more players. Expand There are not more items in the table playerid than if you do it directly in the table data. Unless you load the entire database in to the memory, there is no direct performance benefit gained by the way you do it now (2x indexing is slower). Edited October 17, 2020 by IIYAMA Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now