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 85483 e7142decacd5b7ffec3fb2d4f027f4c71ff64903
parent 85482 0ddce98aaed2e581fdae7d1b0bad0bc49507241b
child 85484 8d39654512d58e9990035f3e7e60f2a4c9bbfb70
push id21925
push usermak77@bonardo.net
push dateThu, 26 Jan 2012 23:13:55 +0000
treeherdermozilla-central@a82c9700c673 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs721320
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.