android - SqliteDatabase Handler - why does first write query take longer than others -
android - SqliteDatabase Handler - why does first write query take longer than others -
i got app database.
it gets called 1 time application class , reference forwarded whoever needs it. when gets initialized phone call db = this.getwritabledatabase();
, leave open. while every write operation of simple double takes around 6-10 ms, frist on needs 30-50 ms 8 times long.
how come? initialization? thought calling getwritabledatabase()
initialize me? or there reason? can read somewhere it, why , how behaves?
thanks in advance
edit: create more clear: values written way after initialization of db handler, initilization long over.
edit 2: digged deeper topic found 2 things:
it said queries on unindexed tables slower. true? doesn't android create index sqlite_autoindex_tablename_1. doesn't solve that? thatgetwritabledatabase()
not open gets loaded when first cursor operation (like cursor.move()
) executed? correct? public sqlitedatabase getwritabledatabase ()
create and/or open database used reading , writing. first time called, database opened ,
oncreate(sqlitedatabase), onupgrade(sqlitedatabase, int, int) and/or onopen(sqlitedatabase) called.
once opened successfully, database cached, can phone call method every time need write database. (make sure phone call close() when no longer need database.)
errors such bad permissions or total disk may cause method fail, future attempts may succeed if problem fixed.
database upgrade may take long time, should not phone call method application main thread, including contentprovider.oncreate(). returns
a read/write database object valid until close() called
throws sqliteexception if database cannot opened writing.
i hope help you.
android database sqlite time
Comments
Post a Comment