MySQL Help

Discussion in 'Plugin Development' started by maxben34, Nov 29, 2014.

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

    maxben34

    I use MySQL to store all the player stats on my server. I use many diffrent tables to store diffrent data for each diffrent class a player can use. The stats are loaded in from the MySQL database (in a async task) when a player joins. They are also saved when a player leaves and every 5 minutes the player is on the server. If multiple players join around the same time it can take from 5 seconds to 2 minutes+ for a players stats to load in. Is there any better way to do this where the stats would load in almost imediately
     
  2. Offline

    Nedinator

    Have a config file for the in between somehow? Have the plugin load what is in the config file and check it with the SQL database. Only SQL I have is using it with a programming language called R.

    I have never worked with MySQL, but I am going to start a project like this. If you wouldn't mind actually PMing me your Skype that'd be great as well.
     
  3. Offline

    mythbusterma

    maxben34

    Erm that seems like something is definitely wrong with your code, how many requests are you making per player?
     
  4. Offline

    ResultStatic

    You should look into connection pooling. Basically connection pooling lets you use multiple Connection objects to concurrently transfer data. Currently your request are happening one after another. Lets say player 1 joins each of the request must wait for each one to finish. If youuse connection pooling it would grab a thread from the pool run its task then put it back once its done. If you are still having problems try optimizing your code or get a better database or run the database on local host. I run mine on local host and it takes less than 30 milliseconds to login a player
     
  5. Offline

    maxben34

    19 queries per player. Yes that's a lot and it wouldn't be if I knew how to efficiently do this.
     
  6. Offline

    mythbusterma

    maxben34

    Well there's your issue. This is also on top of what Result said, that you should be doing them concurrently, rather than sequentially.

    Use pooled connections, multiple threads, and reduce the number of queries and you should be fine.
     
Thread Status:
Not open for further replies.

Share This Page