[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-26 Thread Nathan
The preceding test was with SQLiteDatabase.setLockingEnabled(true), the default. With SQLiteDatabase.setLockingEnabled(false), the reading thread is not starved. Behavior seemed similar to when a transaction was not used. And my tests run successfully. I may be getting lucky and/or my tests are no

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-26 Thread jotobjects
Thanks for that report. Did your transaction test also have the enable locking set? That may have had a worst case exclusive locking effect (SQLite does not use exclusive write locks until commit time normally). FAQs 5 and 6 at this link provide more info - http://www.sqlite.org/faq.html#q5 Ho

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-26 Thread Nathan
>Database engines > usually isolate parallel transactions for multiple clients. Don't count on SQLite doing this. Any locks are on the entire database file - only one transaction can be in progress. I do have some data based on some tests I've run. Having a cursor open does not lock the database

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-22 Thread jotobjects
Interesting. Thanks for that link. It is a reasonable "speculation" (guess) that the enable locking method has "something" to do with the various threading options. In addition to thread safe operation there is the question of how multiple processes (different JVMs) inter-operate with the same S

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-21 Thread Nathan
On Jan 21, 4:22 pm, jotobjects wrote: > > It doesn't make any sense to me that you have to turn locking on > (whatever that means) if you are using transactions.   You probably don't if you are using one thread. I think the setLocking is about making the the SQLite *code* thread safe, and not

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-21 Thread jotobjects
On Jan 21, 12:09 pm, Nathan wrote: > I put a transaction > around a long series of small updates and it was reduced to a few > seconds.  This was a situation where you would think a transaction > would improve correctness, but degrade performance slightly. That is not so surprising since with

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-21 Thread Nathan
On Jan 21, 11:08 am, jotobjects wrote: > You might want to look into the transaction paradigm/pattern: > > http://developer.android.com/reference/android/database/sqlite/SQLite... > > Transactions are the well understood way to get consistent results > with multiple readers and writers.  Exactly

[android-developers] Re: SQLiteDatabase lifecycle and threads

2010-01-21 Thread Nathan
>From the interface methods on SQLiteDatabase, it seems very much like it is intended for one instance of SQLiteDatabase per open database, and that you share it between threads. You can apparently even set locking enabled. = public void setLockingEnabled (boolean lockingEnabled)