On 7 Sep 2016, at 4:36pm, Laura BERGOENS <laura.bergo...@imerir.com> wrote:

> I've put ANALYZE in my code before running this SELECT query, I have no
> change, and now on sqlite3.exe it runs kind of fast every time, even if i
> close and re open the DB, without ANALYZE statement.

Good.  If should now run quickly in your own program too.  This is the 
improvement in speed we expected to see.

The results of ANALYZE are stored in the database file.  You only have to do it 
once.  SQLite creates some hidden tables in the database file and saves the 
results there.  Later commands with a "WHERE" or "ORDER BY" clause cause SQLite 
to take a look at those tables to find the best way to do the search or sort.

So having done ANALYZE once, perhaps using sqlite3.exe, you do not need to 
include it in your own program.  If will find the results that were saved in 
the database file.

The only reason to do ANALYZE again is if you change your database schema 
(make/delete columns, TABLEs or INDEXes), or if the nature of your data changes 
(if you expand from 2 countries to 10 countries, or if you once had 50 managers 
and how have just 5 managers). If the 'chunkiness' of the values in a column 
does not change much, then there is no need to run ANALYZE again just because 
you added or deleted many rows.  At most, some people include it in an 
end-of-year procedure.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to