Bug 721320 - Enable persistent SQLite journal on LocalBrowserDB. r=lucasr
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Thu, 26 Jan 2012 16:30:21 +0100
changeset 86708 e7142decacd5b7ffec3fb2d4f027f4c71ff64903
parent 86707 0ddce98aaed2e581fdae7d1b0bad0bc49507241b
child 86709 8d39654512d58e9990035f3e7e60f2a4c9bbfb70
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs721320
milestone12.0a1
Bug 721320 - Enable persistent SQLite journal on LocalBrowserDB. r=lucasr
mobile/android/base/db/BrowserProvider.java.in
--- a/mobile/android/base/db/BrowserProvider.java.in
+++ b/mobile/android/base/db/BrowserProvider.java.in
@@ -379,18 +379,35 @@ public class BrowserProvider extends Con
         }
 
         @Override
         public void onOpen(SQLiteDatabase db) {
             Log.d(LOGTAG, "Opening browser.db: " + db.getPath());
 
             // From Honeycomb on, it's possible to run several db
             // commands in parallel using multiple connections.
-            if (Build.VERSION.SDK_INT >= 11)
+            if (Build.VERSION.SDK_INT >= 11) {
                 db.enableWriteAheadLogging();
+            } else {
+                // Pre-Honeycomb, we can do some lesser optimizations.
+                Cursor cursor = null;
+                try {
+                    cursor = db.rawQuery("PRAGMA synchronous=NORMAL", null);
+                } finally {
+                    if (cursor != null)
+                        cursor.close();
+                }
+                cursor = null;
+                try {
+                    cursor = db.rawQuery("PRAGMA journal_mode=PERSIST", null);
+                } finally {
+                    if (cursor != null)
+                        cursor.close();
+                }
+            }
         }
     }
 
     private DatabaseHelper getDatabaseHelperForProfile(String profile) {
         // Each profile has a separate browser.db database. The target
         // profile is provided using a URI query argument in each request
         // to our content provider.