sockeqwe / sqlbrite-dao

DAO for SQLBrite
http://hannesdorfmann.com/android/sqlbrite-dao
Apache License 2.0
182 stars 22 forks source link

Too many inserts blocking the UI thread. #44

Closed sandeepgahlawat closed 8 years ago

sandeepgahlawat commented 8 years ago

Hi,

I have more than 800 rows to be inserted and while doing so it blocks the UI thread. Is there a way to run the sqlite insert and update queries on background thread.

P.S i tried using the ObserveOn(Schedulers.computations()) like customerDao.insert(Integer.parseInt(idEdit.getText().toString()), firstnameEdit.getText().toString(), lastnameEdit.getText().toString(), adultCheckBox.isChecked()).ObserveOn(Schedulers.computations()).subscribe(insertSubscription); but nothing happened.

sockeqwe commented 8 years ago

Use subscribeOn() instead of observeOn().

Regarding performance: create one single raw sql inserts with all the data in one single SQL statement: INSERT INTO Foo (1,2,3) , (4,5,6) , (7, 8 ,9) (so specify each item to insert as a tupel)

sandeepgahlawat commented 8 years ago

thank you for such a quick reply

sandeepgahlawat commented 8 years ago

One last thing, does the library has any built in function for implementing the text search on a particular column or do i have to create a virtual table using FTS3 or FTS4 Sqlite extensions and the use the MATCH keyword in the query for it.

sockeqwe commented 8 years ago

No, there is no such functionality provided. You have do to that by your own. You can write raw sql queries to use MATCH keyword.