Hi, I've been working on converting the data variables on my server to a MySQL database due to running into issues with the .csv file overloading and causing lag issues on the server and taking a long period to restart. I've never really had to make a forums post here before because I've usually been able to find fixes to the problems on the forums, but I'm a bit stuck with this one.
Currently I have it so when the player joins, it will grab their information from the database, save it as a variable, and when they leave it will delete the variables so that they are not stored on the server.
Example:
However, after running all of this, it causes a severe lag spike when trying to grab the information as shown here (https://timings.spigotmc.org/?url=qecotatopi).
I'm really not sure whether this is an issue with my code, the plugin or the database, and I would really appreciate if someone could help me out, thanks!
Currently I have it so when the player joins, it will grab their information from the database, save it as a variable, and when they leave it will delete the variables so that they are not stored on the server.
Example:
code_language.skript:
on join:
if {firstjoin::%player%} is not set:
set {firstjoin::%player%} to "%now%"
update "INSERT INTO `Data` (`Player`, `UUID`, `IP`, `First Join`) VALUES ('%player%', '%uuid of player%', '%ip of player%', '%now%')"
set {_UUID::*} to objects in column "UUID" from result of query "SELECT * FROM Data WHERE Player = '%player%'"
set {_IP::*} to objects in column "IP" from result of query "SELECT * FROM Data WHERE Player = '%player%'"
set {_Player::*} to objects in column "Player" from result of query "SELECT * FROM Data WHERE Player = '%player%'"
set {_FirstJoin::*} to objects in column "First Join" from result of query "SELECT * FROM Data WHERE Player = '%player%'"
loop {_UUID::*}:
set {uuid.%player%} to loop-value-1
loop {_IP::*}:
set {ip.%player%} to loop-value-1
loop {_Player::*}:
set {player.%{uuid.%player%}%} to loop-value-1
However, after running all of this, it causes a severe lag spike when trying to grab the information as shown here (https://timings.spigotmc.org/?url=qecotatopi).
I'm really not sure whether this is an issue with my code, the plugin or the database, and I would really appreciate if someone could help me out, thanks!