inserting into a transaction significantly improves speed, because there is only one record in the actall database:
db.beginTransaction(); try { // do the inserts db.setTransactionSuccessful() } finally { db.endTransaction(); }
I once experimented with trying to improve the write speed of about ~ 2000 records, and this was the only big improvement I found.
By doing db.setLockingEnabled(false)
, I think it gave a 1% improvement, but then you should also make sure that no other thread writes to db. Removing redundant indexes can also lead to a slight increase if the table is huge.
pgsandstrom
source share