1. 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 comminuty!

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

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Yaml vs Variables vs Mysql

Discussion in 'Skript' started by TheIronMinerLv, Jul 2, 2017.

Thread Status:
Not open for further replies.
  1. TheIronMinerLv

    Joined:
    Jan 27, 2017
    Messages:
    38
    Likes Received:
    5
    Hello!

    Currently my server is using yaml to store and read all the information of player, so there are many yaml read and write stuff pretty frequently..

    I would like to (maybe) change that as yaml isn't the best solution to store data. First of all - I'm not going to store it just in variables, because they are hard to edit (with yaml I can just edit file..), can be corrupted etc. So I've came up with some ideas:

    1. Still use yaml, but on player join write required data in varibles for future use (don't need to check files on every command operation..)

    2. To use mysql database to store data, I could edit it at any time, on every operation server/script would check required data in the database

    3. Use mysql, but on every player join write data from database to variables for future use.

    Maybe there would be some other ways, I need the best for both efficiency (less server resource usage) and usage (possible to easely edit if needed).
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    How tf are variables harder to edit than a yaml file? What? Have you ever heard of a list variable?? You could save all player data with {%player%::} than an entire file...
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    With edit I mean without use of commands I can open yaml file and change something, how do you think I could do that with variables? Stop server and edit them manually through file? I don't think so.
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    I've messed with MySQL along side of Skript for a little bit. If you're planning on setting data for future use, it's pretty alright; however, when it comes to getting the data- especially frequent data- then you may run into some issues.

    Perhaps times have changed, but this is how it was when I used it:
    Setting data was alright, since you'd just run the code and be on your merry way;
    But when it came to getting data from the database to use at that moment, you'd run the code, but you can't proceed until that data is grabbed, thus causing you to halt your code until the query goes through. I'm not sure if it's gotten better or not; if someone else can pitch in about the issue, that's bee cool.

    As for variables and yaml, they're both pretty alright in their own aspects. If you set up your databases correctly in the Skript config, you really shouldn't run into any corruption; Skript also has its own backup system in case such a thing would happen.

    Using yaml isn't too bad either; I'm assuming you have something like Essentials set up, with a folder containing playerdata with files "%uuid of player%.yml". This isn't really too terrible either, since you know where exactly the file is- it's not like it's searching through the entire folder.

    Granted, they're all useful in their own aspects; but if I had to choose, I'd stick with the yaml layout; maybe I'd make it so it would use variables for some things, but ultimately, I'd just make it update to the yaml files in the end.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Thanks for opinion! How about json? I've heard it is better than yaml, but I haven't used it before..
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    • Agree Agree x 1
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Just put your hands off YAML if you want your server to load things faster. While I understand it is easier to edit/read from YAML, it's still less efficient than variables.
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    I undestand that, so I'm asking what combination or what should I use better. As @Orendigo mentioned, data from mysql database can take some time to load, so maybe I should load that data per-player on player join and write it in variable? Theoretically I could edit it, I don't know. Some members in other posts mentioned json, but I'm not sure of how to properly and even if should I try that.
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    So, I was curious about the subject, so I ran a few test to gather data. My findings were pretty much what I expected after reading @Rezz 's Don't Use Yaml, linked by @Donut.

    Using the script provided in the post mentioned, I gathered data; here are my findings:

    YAML vs. Skript Variable Setting (Unmodified Script)
    [​IMG]
    YAML vs. Skript Variable (Unmodified Script)
    [​IMG]
    Data (Unmodified Script)
    [​IMG]

    I decided to see if using an SQlite database would change anything; it did not, so I decided not to include it in the graphs.

    While it makes sense for Skript's Setting Data to slightly increase (but never strays too far from 1 second), Skript's Getting Data seems to be skewed. This is because of the "Pause" feature used in the testing script, which prevents the server from crashing during YAML getting/setting with large values.

    To counter this, I decided to remove the "Pause" feature, at least to see which values I could get to without the data being skewed, or the server crashing:

    Data (Modified Script)
    [​IMG]

    I was only able to get to 100 Elements without the YAML data being skewed.

    Results:
    For setting data, the difference in efficiency starts to become ever so slightly apparent near the 100 elements mark, and is further amplified with 250 elements and beyond, as the YAML time is nearly +50% of Skript Variables time. When it comes to getting data, the difference is rather similar; the difference in efficiency becomes notable between the 100 elements mark, and the 250 elements mark.

    Conclusion:
    With current addons, YAML data seems to increase exponentially (which supports Rezz's claim of addons needing to read every value). In addition, Skript's Variables are incredibly efficient.

    However, I do not believe this "local ban of YAML until someone makes an efficient addon" mentality is necessary. I'm not saying YAML is the full way to go- I'm just saying if you don't use them for accessing data on the fly, and instead using them for, say, storing data that doesn't change often, or script configurations, you shouldn't see a problem.
     
    • Like Like x 1
    • Winner Winner x 1
    • Useful Useful x 1
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    What. You should never ever edit that file manually... Enable effect commands in your config and do it from console
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    :emoji_astonished: You have too much time on your hands ... useful and thorough info though :emoji_thumbsup:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...