From eb54d55cb9ae403a6824687b44b2ee2fafb8e7c5 Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 1 Mar 2008 06:02:15 +0000 Subject: [PATCH] SqliteMailbox: index columns darcs-hash:20080301060215-5007d-9ca704f66e1582a11798e0050b653b2f21900e7a.gz --- src/org/ibex/mail/SqliteMailbox.java | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/org/ibex/mail/SqliteMailbox.java b/src/org/ibex/mail/SqliteMailbox.java index c423fef..0d80532 100644 --- a/src/org/ibex/mail/SqliteMailbox.java +++ b/src/org/ibex/mail/SqliteMailbox.java @@ -22,7 +22,18 @@ public class SqliteMailbox extends Mailbox.Default implements MailTree { private Connection conn; private static final String columns = " messageid_, from_,to_,date_,subject_,headers_,body_,flags_"; - + private static final String[] indexedColumns = new String[] { + "uid_", + "messageid_", + "flags_", + /* + "from_", + "to_", + "subject_", + "date_" + */ + }; + /** * from http://www.sqlite.org/autoinc.html * "If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT @@ -35,6 +46,7 @@ public class SqliteMailbox extends Mailbox.Default implements MailTree { * allowed and any attempt to insert a new row will fail with an * SQLITE_FULL error. */ + // FIXME: should messageid_ be decared unique? private static final String columns_ = "uid_ INTEGER PRIMARY KEY AUTOINCREMENT, messageid_ unique,from_,to_,date_,subject_,headers_,body_,flags_"; @@ -57,13 +69,9 @@ public class SqliteMailbox extends Mailbox.Default implements MailTree { } else { this.uidValidity = rs.getInt(1); } - try { - //conn.prepareStatement("create virtual table 'mail' using FTS2("+columns_+")").executeUpdate(); - conn.prepareStatement("create table 'mail' ("+columns_+")").executeUpdate(); - } catch (SQLException e) { - /* FIXME */ - } - conn.prepareStatement("create index if not exists uid_index on mail(uid_);").executeUpdate(); + conn.prepareStatement("create table if not exists 'mail' ("+columns_+")").executeUpdate(); + for(String name : indexedColumns) + conn.prepareStatement("create index if not exists "+name+"index on mail("+name+");").executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } -- 1.7.10.4