I am trying to get sqlite much faster in my C ++ program. I believe that the results are far from what should have been.
I have several tables in the database, most of them with several records and one with a large number of records (4986450). It was very difficult to get to this size because the inserts were too large for each transaction and because it was a slow insertion.
On the other hand, now I am making a simple query on this large table, such as
sqlite3_prepare_v2(db,"SELECT * FROM Table where primary_key=?1;",-1, &query,NULL);
sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
....
while(running){
sqlite3_bind_text(query, 1, pkey.c_str(), (int)pkey.size() , SQLITE_STATIC);
int query_status = sqlite3_step(query);
if(query_status == SQLITE_ROW){
data = sqlite3_column_int(query,1);
(... just saving data in a map)
}
}
sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &sErrMsg);
(I just changed the table and column names for simplicity). This request is executed after some time and is executed many times in one transaction. It takes about 9 seconds 500 times to request a selection. Even when I inserted data into a table, I could get better times.
PRAGMA main.page_size = 4096;
PRAGMA main.cache_size=10000;
PRAGMA main.locking_mode=EXCLUSIVE;
PRAGMA main.synchronous=OFF;
PRAGMA main.journal_mode=WAL;
PRAGMA main.cache_size=5000;
? ?