Detecting forgotten SQLite transaction on Android using StrictMode?

谁说我不能喝 提交于 2020-01-12 08:06:22

问题


Executing multiple SQL statements without putting them into one transaction is a severe bottleneck (see e.g. http://www.sqlite.org/faq.html#q19). I haven't thoroughly checked how SQLite is configured on Android, but anecdotally I perceived dramatical performance increase within my on app when using transactions in more places.

Is it possible to detect instances where one forgets to use transactions using StrictMode? If not, could that be considered for a future release of StrictMode? It might be somewhat tricky to detect, but two different strategies could be, 1) non-select statements outside transaction, or 2) multiple non-select statements outside transaction executed within a short period of time.


回答1:


Yeah, that sounds like a good thing to catch. I could imagine an API like:

StrictMode.catchWritesOutsideTransactionsOn(SQLiteDatabase db);

We've been considering other SQLite hooks into StrictMode (mostly around selects missing indexes and such), but this is a good idea too!



来源:https://stackoverflow.com/questions/4433629/detecting-forgotten-sqlite-transaction-on-android-using-strictmode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!