jeudi 28 mai 2015

Slow perfomance of SQlite-query

at first I used an AsyncTask for getting data from MySQL server. logcat:

05-28 19:35:05.172  18204-18204/eu.straff D/START? START
05-28 19:35:05.172  18204-18243/eu.straff D/AsyncTask? AsyncTask
05-28 19:35:06.442  18204-18243/eu.straff D/firstchar? {
05-28 19:35:06.442  18204-18243/eu.straff D/JSON_Check? JSONObject
05-28 19:35:06.442  18204-18243/eu.straff E/jsonStr? {"tag":"request_ean","success":1,"error":0,"bezeichnung":"PKW \r","art":null,"stammkost":null,"marker":null}
05-28 19:35:06.442  18204-18204/eu.straff I/Timeline? Timeline: Activity_launch_request id:eu.straff time:924198233
    --------- beginning of /dev/log/system
05-28 19:35:06.492  18204-18204/eu.straff D/END? END

this are 1.32 seconds

To improve the mobile use without network connection I put the MySQL (via PHP) into SQlite database: The query:

if(c.moveToFirst())
            {
                    bezeichnung = c.getString(2);
                    if(bezeichnung != null && !bezeichnung.isEmpty()) {Log.d("bezeichnung", bezeichnung);} else {bezeichnung = "null";Log.d("bezeichnung", bezeichnung);}
                    art = c.getString(3);
                    if(art != null && !art.isEmpty()) {Log.d("art", art);} else {art = "null";Log.d("art", art);}
                    stammkost = c.getString(4);
                    if(stammkost != null && !stammkost.isEmpty()) {Log.d("stammkost", stammkost);} {stammkost = "null"; Log.d("stammkost", stammkost);}
                    marker = c.getString(5);
                    if(marker != null && !marker.isEmpty()) {Log.d("marker", marker);} {marker = "null"; Log.d("marker", marker);}
            }

logcat:

05-28 19:36:31.602  19546-19546/eu.straff D/START? START
05-28 19:36:32.762  19546-19546/eu.straff D/bezeichnung? PKW
05-28 19:36:32.762  19546-19546/eu.straff D/art? null
05-28 19:36:32.762  19546-19546/eu.straff D/stammkost? null
05-28 19:36:32.762  19546-19546/eu.straff D/marker? null
05-28 19:36:32.762  19546-19546/eu.straff I/Timeline? Timeline: Activity_launch_request id:eu.straff time:924284555
    --------- beginning of /dev/log/system
05-28 19:36:32.792  19546-19546/eu.straff I/Choreographer? Skipped 71 frames!  The application may be doing too much work on its main thread.
05-28 19:36:32.812  19546-19546/eu.straff D/END? END

Here are 1.21 seconds for the same output.

Should the use of SQLite not be much faster? Its not neccessary to send the query and receive the answer. The SQlite-db is about 4.756 KB with 68968 row and 6 columns. The MySQL-db is using a LEFT JOIN.

You got the same results/conclusion that SQLite isnt much faster?

Aucun commentaire:

Enregistrer un commentaire