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

yaml VS sql

Comments in 'Plugin Development' started by Svile, Feb 9, 2016.

  1. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Wich one is better to store only player money ? why ? differences ?
    I think creating different files for each player (like SimpleAuth by shoghicp or Economy$ by onebone) is better.
    Thanks :)
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    SQL is faster.
    applqpak and AndrewBit like this.
  3. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    SQL is very useful when you want to share data between servers
    AndrewBit and applqpak like this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I am a fan of JSON! :D
    In HereAuth, I saved skins, making each file larger than 4 KB. Therefore, I used JSON + GZIP, making the files formatted in .json.gz

    So, my comparison:

    File-based vs table-based
    This is basically YAML vs SQL, as the thread is above.
    File-based is good when you want a simple solution to save data at small units, say, per player. However, a problem is that it creates a large number of files, which many users may dislike. Also, if the units are related, e.g. you want to find the average, standard deviation or extrema of the data, you may either:
    • Load the data of all units every time. If you have 100000 players registered, it is an issue. You have to open stream for each unit, read, and close stream. This has very poor performance, especially on personal computers, whose harddisks don't expect you to read so many files at a time.
    • Store the values. If you want a sum, alter the value every time a datum is added/removed/updated. If you want an average, store the count in addition. If you want top 10, it would be even more troublesome. If you want the standard deviation, a lot of trouble. If you want the median, impossible unless you use the method above (recalculate every time).
    On the other hand, using table-based database (SQL) can overcome these problems. If you use a MySQL storage, you just need to create asynchronous connections and performance isn't a problem. If you use an SQLite3 storage, you can create a database at :memory:, which allows querying from memory. Then you can periodically use asynchronous tasks to export data into the harddisk by creating a single file of any format you like. It will come out well if you can use it properly.

    A third solution
    Why argue so much? Just let the users pick what database to use and bear their own consequences! See SimpleAuth for how to support switching between multiple database types.

    YAML vs JSON
    YAML is really good. But I don't like its strict and ambiguous requirements on indentation. Instead, although slightly verbose, JSON is easier to understand and much clearer.
    CrazedMiner and Svile like this.

Share This Page

Advertisement