[Solved] how to speed up. QSQLite INSERT query?
-
You should probably check this "faq":http://www.sqlite.org/faq.html#q19.
-
I do it like described "here":http://doc.qt.nokia.com/4.7/qsqlquery.html#prepare.
This works fine and is fast enough for my software.
Don't forget the @db.transaction()@ and @db.commit()@ before and after your query.
-
[quote author="shint" date="1296545085"]
//use prepare. addBindValue.
@
QString tmp, str;
for(int row = 0; row < nRowCount; row++)
{
query.prepare(qsInsertTable);
int nValueCount = 0;
for(int col = 0; col < nColumnCount; col++)
{
@[/quote]You should prepare your statement once (outside the for row statement) and use it multiple times. You actually do it the other way round: You create a single new prepared statement for each row you insert. This does not save you time, but cost you.
-
[quote author="Volker" date="1296556882"]
[quote author="shint" date="1296545085"]
//use prepare. addBindValue.
@
QString tmp, str;
for(int row = 0; row < nRowCount; row++)
{
query.prepare(qsInsertTable);
int nValueCount = 0;
for(int col = 0; col < nColumnCount; col++)
{
@[/quote]You should prepare your statement once (outside the for row statement) and use it multiple times. You actually do it the other way round: You create a single new prepared statement for each row you insert. This does not save you time, but cost you.[/quote]
Good point! I haven't seen this.