Hello,

I am using sqlite C API to migrate a database. Migration consists of many SQL statements that are known in advance.

To migrate a DB from version 3 to version 7 the C program does the following:

1. disable foreign_keys (PRAGMA foreign_keys = OFF);
2. open transaction (BEGIN TRANSACTION);
3. execute bunch of statements that migrates the DB to the next version
   using *sqlite3_exec(db, migrate[version], NULL, NULL, &errMsg)*;
   migrate[version] is consisting of many (sometimes several thousand)
   statements;
4. check for foreign_keys inconsistencies (PRAGMA foreign_key_check);
5. commit transaction (COMMIT TRANSACTION);
6. enable foreign_keys again (PRAGMA foreign_keys = ON);
7. vacuums db file (vacuum);


I've realized that using the command line tool the migration takes around 8 minutes, but the C program takes around 20 minutes. This time is consumed in point number 3 in the previous list.

How can I increase the performance of my program so that it reaches the performance of the command line tool?

My first bet is to prepare each individual statement and then execute it. Should it be faster than sqlite3_exec?

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

Reply via email to