Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Speed up database update
Browse files Browse the repository at this point in the history
Drop the trigger on sync_id before doing a bulk update of sync_id
fields.  This dramatically reduces the time required for the
calendar database update when there are lots of events.

Bug 5699796

Change-Id: I94c2fb624b5b63bfdf760b3092697f9205a634c9
  • Loading branch information
fadden committed Dec 5, 2011
1 parent 7c5e457 commit 3ac8148
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -1512,14 +1512,19 @@ void upgradeToVersion306(SQLiteDatabase db) {
* Change event id's from ".../private/full/... to .../events/...
* Set Calendars.canPartiallyUpdate to 1 to support partial updates
* Nuke sync state so we re-sync with a fresh etag and edit url
*
* We need to drop the original_sync_update trigger because it fires whenever the
* sync_id field is touched, and dramatically slows this operation.
*/
db.execSQL("DROP TRIGGER IF EXISTS original_sync_update");
db.execSQL("UPDATE Events SET "
+ "_sync_id = REPLACE(_sync_id, '/private/full/', '/events/'), "
+ "original_sync_id = REPLACE(original_sync_id, '/private/full/', '/events/') "
+ "WHERE _id IN (SELECT Events._id FROM Events "
+ "JOIN Calendars ON Events.calendar_id = Calendars._id "
+ "WHERE account_type = 'com.google')"
);
db.execSQL(CREATE_SYNC_ID_UPDATE_TRIGGER);

db.execSQL("UPDATE Calendars SET canPartiallyUpdate = 1 WHERE account_type = 'com.google'");

Expand Down

0 comments on commit 3ac8148

Please sign in to comment.