Can MySQL connection cause lag?

Discussion in 'Plugin Development' started by Swakiny, Feb 28, 2016.

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

    Swakiny

    I was thinking about storing player mob kills in a database, so...
    It will lag the server? Creating a connection every time when a zombie dies, skeletons etc dies...?
     
  2. Offline

    boomboompower

    @Swakiny
    I don't believe so, I don't really work with SQL so not sure.
     
  3. Offline

    Swakiny


    I done a code and its lagging. Maybe because I'm from Brazil and my database is located in Texas.
    But, if I put my server in the same server as database, will lag stop? nvm i'll try to creat a localhost data-base and see what happens
     
  4. Offline

    mythbusterma

    @boomboompower @Swakiny

    Yes. There is an indeterminate amount of time between when you make an SQL query and when you get an answer, so waiting on a response on the main thread will "lag" the server. A lot.

    Don't use SQL if you don't need it, it's not faster, and it's not easier. If you actually need it for some reason, all SQL requests should be done on another thread. Make sure that you write thread safe code.

    Creating a connection is a particularly expensive process, connections should be cached rather than recreated.
     
    mine-care likes this.
Thread Status:
Not open for further replies.

Share This Page