On 13 Jun 2017, at 10:53am, rv.gauth...@free.fr wrote:
> Is there a way (pragma, compile flags, ...) to gain these 14 ms for the first > query ? In SQLite, it is transactions which take all the time. Individual commands such as SELECT are fast. What takes the time is the locking, journal access, database updating, etc. that happens at the end of a transaction. The rules for SQL state that file access must be done within a transaction. You would expect that if you did SELECT without having first done BEGIN, you would get an error message. However, SQLite is very nice to you and if it thinks you forgot to make a transaction it will make one for you, by wrapping your SELECT as BEGIN ... SELECT ... END . This explains why a SELECT by itself takes a lot of time, whereas a SELECT inside a transaction is faster. Also please note that SQLite does a 'lazy open'. When you create your connection to the database file, SQLite doesn’t actually open the file. Instead the file handling is done the first time SQLite needs the data from the file. So the first SELECT after a new connection is made takes longer than the others. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users