commit d7ac5eb038aba06ff1a4426b7fd941b281a51657
Author: Christophe Fergeau <[email protected]>
Date: Wed Oct 28 14:14:18 2009 +0100
don't recreate sqlite3 queries in inner loops
For now, this is just an attempt to speed up sqlite writing. This commit
moves sqlite3_prepare/sqlite3_finalize out of the loop iterating over
all the tracks and use sqlite3_reset between iterations. The timings
with/without this need to be compared.
src/itdb_sqlite.c | 25 ++++++++++++++++---------
1 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/itdb_sqlite.c b/src/itdb_sqlite.c
index 5f05b57..81d44b2 100644
--- a/src/itdb_sqlite.c
+++ b/src/itdb_sqlite.c
@@ -94,16 +94,17 @@ static void mk_Dynamic(Itdb_iTunesDB *itdb, const char
*outpath)
GList *gl = NULL;
printf("[%s] - processing %d tracks\n", __func__,
g_list_length(itdb->tracks));
+ if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_stats\"
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt, &sqltail)) {
+ fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__,
sqlite3_errmsg(db));
+ printf("[%s] -- inserting into \"item_stats\"\n", __func__);
+ goto leave;
+ }
for (gl=itdb->tracks; gl; gl=gl->next) {
Itdb_Track *track = gl->data;
if (!track->ipod_path) {
continue;
}
-
- printf("[%s] -- inserting into \"item_stats\"\n", __func__);
- if (SQLITE_OK != sqlite3_prepare_v2(db, "INSERT INTO \"item_stats\"
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", -1, &stmt, &sqltail)) {
- fprintf(stderr, "[%s] sqlite3_prepare error: %s\n", __func__,
sqlite3_errmsg(db));
- } else {
+ {
int res;
idx = 0;
/* item_pid */
@@ -145,11 +146,17 @@ static void mk_Dynamic(Itdb_iTunesDB *itdb, const char
*outpath)
} else {
fprintf(stderr, "[%s] 1 sqlite3_step returned %d\n",
__func__, res);
}
+ res = sqlite3_reset(stmt);
+ if (res == SQLITE_DONE) {
+ /* expected result */
+ } else {
+ fprintf(stderr, "[%s] 1 sqlite3_reset returned %d\n",
__func__, res);
+ }
}
- if (stmt) {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
+ }
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ stmt = NULL;
}
} else {
printf("[%s] - No tracks available, none written.\n", __func__);
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2