我正在尝试将行插入 SQLite DB。插入 130 行需要 7 秒,这对我来说似乎很慢。
表定义为:
sd.execSQL("CREATE TABLE " + V2VocabsTable.TABLE_NAME + " ("
+ V2VocabsTable.ID + " VARCHAR(10) PRIMARY KEY ,"
+ V2VocabsTable.NAME + " VARCHAR(255), "
+ V2VocabsTable.LOADED + " VARCHAR(1) "
+ ");"
);
要插入一行,我使用以下代码:
public void addTableStatus(String tableId, String name) {
Log.d("DB","Before Insert");
ContentValues cv = new ContentValues();
cv.put(V2VocabsTable.ID, "Table " + tableId);
cv.put(V2VocabsTable.NAME, name);
cv.put(V2VocabsTable.LOADED, "NO");
SQLiteDatabase sd = getWritableDatabase();
long result = sd.insert(V2VocabsTable.TABLE_NAME, null, cv);
Log.d("DB","After Insert :: " + result);
}
日志文件中的时间是:
12-17 23:00:11.445: D/SQLDB(25384): Init
12-17 23:00:11.455: D/DB(25384): Before Insert
12-17 23:00:11.505: D/SQLDB(25384): Open
12-17 23:00:11.895: D/DB(25384): After Insert :: 1
12-17 23:00:11.895: D/DB(25384): 0001 :: AdministrativeSex-v1.0.xml
12-17 23:00:11.895: D/DB(25384): Before Insert
12-17 23:00:11.965: D/DB(25384): After Insert :: 2
12-17 23:00:11.965: D/DB(25384): 0002 :: MaritalStatus-v1.0.xml
12-17 23:00:11.965: D/DB(25384): Before Insert
12-17 23:00:12.005: D/DB(25384): After Insert :: 3
12-17 23:00:12.005: D/DB(25384): 0004 :: PatientClass-v1.0.xml
12-17 23:00:12.005: D/DB(25384): Before Insert
12-17 23:00:12.145: D/DB(25384): After Insert :: 4
12-17 23:00:18.815: D/DB(25384): Before Insert
12-17 23:00:18.865: D/DB(25384): After Insert :: 131
12-17 23:00:18.865: D/DB(25384): ZU057 :: LocationHiding-v1.0.xml
12-17 23:00:18.865: D/DB(25384): Before Insert
12-17 23:00:18.925: D/DB(25384): After Insert :: 132
这对我来说似乎太慢了,什么可能会减慢它的速度?