From 3ac8148cdc79bde4b009ccb6a9ffda77bdb547d3 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 2 Dec 2011 16:47:38 -0800 Subject: [PATCH] Speed up database update 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 --- .../android/providers/calendar/CalendarDatabaseHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/android/providers/calendar/CalendarDatabaseHelper.java b/src/com/android/providers/calendar/CalendarDatabaseHelper.java index d609bdf1..db702695 100644 --- a/src/com/android/providers/calendar/CalendarDatabaseHelper.java +++ b/src/com/android/providers/calendar/CalendarDatabaseHelper.java @@ -1512,7 +1512,11 @@ 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/') " @@ -1520,6 +1524,7 @@ void upgradeToVersion306(SQLiteDatabase db) { + "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'");