If you don't perform inserts, updates, and deletes in a transaction, each insert, update, and delete will be committed using an implicit transaction which will definitely slow down your program.
Try wrapping your CRUD statements with a transaction as shown below:
lite_db.transaction();
// do all of your inserts/updates/deletes
lite_db.commit(); // commit changes if successful or lite_db.rollback(); if you encountered an error, etc.
lite_db.transaction();
// do all of your inserts/updates/deletes
lite_db.commit(); // commit changes if successful or lite_db.rollback(); if you encountered an error, etc.
To copy to clipboard, switch view to plain text mode
Another optimization would be to prepare your insert statement and use QSqlQuery::bindValue() to bind values to the named or unnamed query parameters, etc. Preparing the insert statement allows the db engine to optimize the query.
Hope that helps.
Bookmarks