On 7 Feb 2011, at 3:12pm, Sven L wrote:

> I've discovered that the ANALYZE command is extremely slow on my large 
> databases. I read the documentation and it says that the command should be 
> issued when the schema is changed "a lot". Hmm, when exactly could that be? 
> Currently, I issue the command every time I have inserted ~1000 rows in my 
> main table.

You should never need the ANALYZE command in a routine your users run.  If your 
first 1000 rows are representative of the 'chunkiness' of your data, do it 
once, then there's no need to issue that command ever again.

The results are used only to help the query analyser choose which order to 
consider columns in.  In order to do this it's useful to know things like "The 
column called 'currency' is almost always the same value, whereas the column 
called 'totalAmount' changes a lot.".  That's what that command does.  If you 
radically changed your data by, for example, moving from a national to an 
international service then it might be worth running ANALYZE again once you had 
a bunch of invoices in other currencies in, but only then, and only once.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to