Slight lag when using MySQL via. SkQuery

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Cybers_

Member
Feb 21, 2017
18
2
0
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:

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!
 
place the code into a function, run the function on login async
example:

$ thread
fetchData(player)
 
Status
Not open for further replies.