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

SQLite query speed?

Comments in 'Plugin Development' started by Legoboy0215, Feb 25, 2016.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Do I need to use an async task when querying stuff? Would it be better using this for storage instead of MySQL?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Anything that involves disk I/O or CPU-intensive processing is better with AsyncTask. The problem is whether it is worth the cost spending time to handle the trouble of asynchronous programming, if it outweighs the performance improvement. For SQLite3, I don't think it is really necessary.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Why? I thought you just create or code a usable MySQL / SQLite async task, then just basically use it over and over.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, but it is actually very troublesome to handle data asynchronously. For example, if you need to asynchronously handle events that are cancellable, you have to think of how to cancel them outside the event, e.g. for move events, teleport them back later, or for damage events, don't let them die until you have ensured that they should die. These are troublesome and annoying.
    Moreover, the async query mechanism I suggested before will create a database instance in every async worker thread. This is not so good for SQLite - although SQLite also supports concurrent editing, it doesn't do things as well as MySQL. Your tasks easily hang or error if you use the same SQLite database from multiple threads. MySQL, after all, supports all these much better. This is personal experience.
    However, after all, SQLite doesn't really create much lag if you use it properly.
    It might even be better to create the database at ":memory:", where it won't create a database on the harddisk, and you can write out the data in your own format upon save/load.

Share This Page

Advertisement