On 4 Jan 2016, at 6:47am, ??? <2004wqg2008 at 163.com> wrote: > Before I retrieve the record from the sqlite data base, I execute vacuum > function. > Can this method improve the speed of retrieve the records from sqlite data > base?
The VACUUM function takes so long to run that you cannot get faster overall. Depending on which operating system, file system and storage system you use, it is possible for VACUUM to increase speed of SELECT a little, but not much [1]. Certainly not enough to make up for the time VACUUM takes. To find out the effect on your specific platform you must perform the test on your specific platform. For those who wonder, storage speeds used to be governed very strongly by fragmentation, and there used to be a great advantage to systems which read and returned the block you asked for, then read and cached the following block. For systems which implement this, defragmentation definitely increases speed. However modern systems, many of which use SSD instead of spinning drive, and many of which are constantly writing log files in the background, gain almost no advantage from defragmentation. Simon.