Detect forgotten SQLite transaction on Android using StrictMode?

Executing multiple SQL statements without putting them in a single transaction is a serious bottleneck (see, for example, http://www.sqlite.org/faq.html#q19 ). I did not fully check how SQLite is configured on Android, but by all accounts, I felt a dramatic increase in performance in my application when using transactions in more places.

Is it possible to detect cases when one of them forgets to use transactions using StrictMode? If not, can this be considered for a future release of StrictMode? This may be somewhat difficult to detect, but there may be two different strategies: 1) non-selectable statements outside the transaction, or 2) several non-selected statements outside the transaction performed in a short period of time.

+5
source share
1 answer

Yes, that sounds like a good thing to catch. I could imagine the API:

StrictMode.catchWritesOutsideTransactionsOn(SQLiteDatabase db);

We looked at other SQLite hooks in StrictMode (mainly around selecting missing indexes, etc.), but this is also a good idea!

+3
source

All Articles