[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Marco Nelissen
On Wed, May 20, 2009 at 2:50 PM, Sublimity Mobile Software < sublimitysoftw...@gmail.com> wrote: > > My current database layer is used to convert query results into bean > objects. I did a test and the results where: > > Total time loading queries = 15273ms > Queries executed = 561 > Executing All

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Dianne Hackborn
I think there is still some misunderstanding. The problem is NOT the getCount() method, that just happens to be where the query is performed. If you move your code around, you are just going to move around whatever the first call you make that actually performs the query. If the majority of your

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Sublimity Mobile Software
My current database layer is used to convert query results into bean objects. I did a test and the results where: Total time loading queries = 15273ms Queries executed = 561 Executing All Queries = 3781 ( ~25% of the total time ) GetCount() method uses = 7291ms ( ~48% of the total time ) Loaded

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Streets Of Boston
really...? That's surprising. I thought the moveToNext just fetches the rows lazily, fetches them when necessary. On May 20, 2:15 pm, Marco Nelissen wrote: > The first call to moveToNext() is still going to cause getCount() and > thus fillWindow() to be called internally, so it won't be any fast

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Marco Nelissen
The first call to moveToNext() is still going to cause getCount() and thus fillWindow() to be called internally, so it won't be any faster. On Wed, May 20, 2009 at 10:58 AM, Streets Of Boston wrote: > > In your example, it seems you don't need the getCount() or moveToFirst > () at all. > > The

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Streets Of Boston
In your example, it seems you don't need the getCount() or moveToFirst () at all. The snippet below works well without using getCount or moveToFirst(). [code] Cursor c = db.query(var1, var2, var3 .); while (c.moveToNext()) { // do something with cursor c ... } [/code] On May 18, 10:47 

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Marco Nelissen
If you're sure there is nothing to be gained from optimizing the database itself, then it seems your only option is to not use a database at all. Are you *sure* the database/query can't be further optimized? How much time does your query take anyway? On Wed, May 20, 2009 at 2:17 AM, Sublimity Mo

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-20 Thread Sublimity Mobile Software
Thank you for your reply. You where right. The getCount() method takes indeed a lot of time. So i filled another window by using fillWindow() like this: Cursor c = db.query(var1, var2, var3 .); SQLiteCursor liteCursor = (SQLiteCursor) c; CursorWindow cw = new CursorWindow(true); liteCursor.f

[android-developers] Re: Cursor.moveToFirst() is taking up a lot of time

2009-05-18 Thread Marco Nelissen
On Mon, May 18, 2009 at 7:47 AM, Sublimity Mobile Software wrote: > > Hi, > > Currently i'm working on a database system for some applications. I > need to do a lot of queries to load data from the database into the > application. After being amazed how much time it took to do these > queries on