On 6 Aug 2013, at 3:23am, Bo Peng <ben....@gmail.com> wrote:

> For
> example, if we create 1000 tables and insert records to them in batch,

Do you really have 1000 different schemas so you need 1000 different tables to 
store data ?  Can these not be merged into one table ?  Merging those would 
provide significant increase in speed.  In a SQLite database tables are 
arranged in a list.  If you access a random table and have 1000 tables in a 
database file, SQLite has to look down an average of 500 tables in the list 
before it finds the one you want.  If the table name is just a value in a 
column then it can use indexes you've created to jump straight to the rows you 
want.

> the data of each table will likely spread evenly across the whole
> database, and almost all pages need to be read when we go through
> records of a table.

Do a VACUUM during downtime, probably overnight.  Of course, you will need 
disks which are up to three times the size of your database to make sure the 
VACUUM can complete.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to