mozilla-services/android-sync — comment on commit b22efc7db4e9df28155013643cdde3ecb07a0c82
File: src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserHistoryDataExtender.java line 135
By marina-samuel:

Here's an idea (not sure how well it would work, but you can consider it):

It looks like SQLiteDatabase.update() returns an int for number of affected rows. So why not attempt an update first, if 0 rows are affected, then do an insert? This would save you the fetch at the beginning.