Hi, My sqlite is configure as serialized (THREADSAFE=1). My application has only one connection but it is shared by two thread. One thread will do insert/update/delete in the background , another thread will do the select upon request of the user from gui. Typically, we will call following function 12 times (with different parameters ,of course)before showing the pages to user. In the standalone test (single thread), a call to following function will take less than 40ms, so 12 times will take less than 500 ms and it is acceptable. However, in the real application, sometimes this function took 1000ms to return the result which make the gui slow.
int search_eit_event_in_time_inteval(...) 86 { 93 94 sql = (char *)" SELECT *,rowid FROM tblEvent_basic " 95 " WHERE " 96 " service_id = ? AND " 97 " start_time < ? AND end_time > ? " 98 " ORDER by start_time ASC"; } I did some experiment try to understand why this happend? Here is the code I used : http://pastebin.ca/1509723 I found : 1. When i create a write_thread a. with usleep(10000) in while(1) search time always < 50ms b. without usleep(10000) in while(1) 17.7 % search time > 50ms , usually 200ms 2. When i create another_thread (no database access at all) a. with usleep(10000) in while(1) search time always < 50ms b. without usleep(10000) in while(1) 21.7 % search time > 50ms , usually 200ms. Any insight? Should I go with THREADSAFE=2 and two connections: one for read ,another for write? Thanks. -- View this message in context: http://www.nabble.com/search-time-is-non-determinate-in-multi-thread-enviroment-tp24693604p24693604.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users