add fastButDangerous to SqliteTable
authoradam <adam@megacz.com>
Sat, 17 Mar 2007 09:02:45 +0000 (09:02 +0000)
committeradam <adam@megacz.com>
Sat, 17 Mar 2007 09:02:45 +0000 (09:02 +0000)
darcs-hash:20070317090245-5007d-82f91cc9d11d57861265bb003698da62e0a60bc8.gz

src/org/ibex/mail/SqliteTable.java

index 085a9b6..91dcb53 100644 (file)
@@ -19,12 +19,21 @@ public class SqliteTable {
     private String reapColumn;
 
     public SqliteTable(String filename, String[] tables, String reapTable, String reapColumn) {
+        this(filename, tables, false, reapTable, reapColumn);
+    }
+    public SqliteTable(String filename, String[] tables, boolean fastButDangerous,
+                       String reapTable, String reapColumn) {
         this.filename = filename;
         try {
             Class.forName("org.sqlite.JDBC");
             conn = DriverManager.getConnection("jdbc:sqlite:"+filename);
             for(String s : tables)
                 conn.prepareStatement(s).executeUpdate();
+            conn.prepareStatement("PRAGMA temp_store = MEMORY").executeUpdate();
+            conn.prepareStatement("PRAGMA page_size=4096").executeUpdate();
+            conn.prepareStatement("PRAGMA cache_size=2000").executeUpdate();
+            if (fastButDangerous)
+                conn.prepareStatement("PRAGMA synchronous = OFF").executeUpdate();
         }
         catch (SQLException e) { throw new RuntimeException(e); }
         catch (ClassNotFoundException e) { throw new RuntimeException(e); }
@@ -62,4 +71,4 @@ public class SqliteTable {
         }
     }
 
-}
\ No newline at end of file
+}