add fastButDangerous to SqliteTable
[org.ibex.mail.git] / 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
+}