On Sat, Oct 23, 2010 at 02:12:19AM +0400, Max Vlasov wrote: > As for your initial question, I think fragmentation evaluation is possible > with the help of VFS. I'd keep a total sum of of absolute difference between > consequent read offsets for xRead operation. In this case if some xRead > request reads 1024 bytes at the 4096 offset and the next xRead reads > something at 5120 (4096 +1024) this will add 0 to the sum, but if the next > read something at 8192, this will add 3072 = (8192 - (4096 +1024)). If this > implemented, you will be able to see how this value changes for some of your > SELECT and maybe evaluate it on per record basis. If it's more like some > threshold value, ok, peform VACUUM
SQLite knows when it's generating full table scans, so it could arrange to detect non-sequential I/O for just that table's B-Tree (random I/O might result anyways if the query is a join, say), gather rudimentary statistics (say, the number of non-sequential page reads for the table scan) and report fragmentation via a pragma. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users