From a0cb28b1046245eeaa1fdc97212841809903c5a2 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Tue, 12 Mar 2013 16:19:47 -0400 Subject: [PATCH] Bug 826476 - Modify sqlite database pragmas to possibly improve performance r=kats --- .../android/base/db/BrowserProvider.java.in | 26 +++++++++---------- mobile/android/base/db/TabsProvider.java.in | 15 ++++++----- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/mobile/android/base/db/BrowserProvider.java.in b/mobile/android/base/db/BrowserProvider.java.in index e316e544990..775f7f08a46 100644 --- a/mobile/android/base/db/BrowserProvider.java.in +++ b/mobile/android/base/db/BrowserProvider.java.in @@ -1727,13 +1727,18 @@ public class BrowserProvider extends ContentProvider { debug("Opening browser.db: " + db.getPath()); Cursor cursor = null; - if (Build.VERSION.SDK_INT >= 8) { - try { - cursor = db.rawQuery("PRAGMA foreign_keys=ON", null); - } finally { - if (cursor != null) - cursor.close(); - } + try { + cursor = db.rawQuery("PRAGMA foreign_keys=ON", null); + } finally { + if (cursor != null) + cursor.close(); + } + cursor = null; + try { + cursor = db.rawQuery("PRAGMA synchronous=NORMAL", null); + } finally { + if (cursor != null) + cursor.close(); } // From Honeycomb on, it's possible to run several db @@ -1743,13 +1748,6 @@ public class BrowserProvider extends ContentProvider { } else { // Pre-Honeycomb, we can do some lesser optimizations. 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 { diff --git a/mobile/android/base/db/TabsProvider.java.in b/mobile/android/base/db/TabsProvider.java.in index fa28d84b977..5f0229b7c39 100644 --- a/mobile/android/base/db/TabsProvider.java.in +++ b/mobile/android/base/db/TabsProvider.java.in @@ -189,19 +189,20 @@ public class TabsProvider extends ContentProvider { public void onOpen(SQLiteDatabase db) { debug("Opening tabs.db: " + db.getPath()); + Cursor cursor = null; + try { + cursor = db.rawQuery("PRAGMA synchronous=OFF", null); + } finally { + if (cursor != null) + cursor.close(); + } + // From Honeycomb on, it's possible to run several db // commands in parallel using multiple connections. 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);