So, I think I may have narrowed it down to a problem with System.Data.SQLite. I tried the following code in C ++:
#include "sqlite3.h" #include <stdio.h> void xProfile(void* pArg, const char* query, sqlite3_uint64 pTimeTaken) { printf("%s\n", query); printf("%I64d ms\n", pTimeTaken / 1000000); } void PoorPerformance(); void GoodPerformance(); int main() { printf("Poor Performance:\n"); PoorPerformance(); printf("Good Performance:\n"); GoodPerformance(); return 0; } void PoorPerformance() { int rc; int rowCount = 0; sqlite3 *db; if (sqlite3_open("<<File Here>>", &db)) { printf("Could not open the database."); return; } sqlite3_profile(db, &xProfile, NULL); sqlite3_stmt *statement; if (!sqlite3_prepare_v2(db, "SELECT * FROM SearchResults WHERE ContactName LIKE @ContactName;", -1, &statement, 0)) { int result = 0; int parameterIndex = sqlite3_bind_parameter_index(statement, "@ContactName"); sqlite3_bind_text(statement, 1, "test", -1, NULL); while (result != SQLITE_DONE) { result = sqlite3_step(statement); if (result == SQLITE_ROW) { rowCount++; } } sqlite3_finalize(statement); } printf("%d rows\n", rowCount); sqlite3_close(db); } void GoodPerformance() { int rc; int rowCount = 0; sqlite3 *db; if (sqlite3_open("<<File Here>>", &db)) { printf("Could not open the database."); return; } sqlite3_profile(db, &xProfile, NULL); sqlite3_stmt *statement; if (!sqlite3_prepare_v2(db, "SELECT * FROM SearchResults WHERE ContactName LIKE 'test';", -1, &statement, 0)) { int result = 0; while (result != SQLITE_DONE) { result = sqlite3_step(statement); if (result == SQLITE_ROW) { rowCount++; } } sqlite3_finalize(statement); } printf("%d rows\n", rowCount); sqlite3_close(db); }
Both the PoorPerformance and GoodPerformance functions gave 1 ms with 11 lines. Is there something else between what I did and what System.Data.SQLite should have done? Hope this is just what I can report as an error with System.Data.SQLite and maybe apply my own fix.
Terry
source share