Usually when I have programs that are doing a full disk scan and going over all files in the system they take a very long time to run. Why does updatedb run so fast in comparison?
Why does the `updatedb` program run so fast
performanceupdatedb
performanceupdatedb
Usually when I have programs that are doing a full disk scan and going over all files in the system they take a very long time to run. Why does updatedb run so fast in comparison?
Best Answer
The answer depends on the version of
locate
you’re using, but there’s a fair chance it’smlocate
, whoseupdatedb
runs quickly by avoiding doing full disk scans:(The database stores each directory’s timestamp,
ctime
ormtime
, whichever is newer.)Like most implementations of
updatedb
,mlocate
’s will also skip file systems and paths which it is configured to ignore. By default there are none inmlocate
’s case, but distributions typically provide a basicupdatedb.conf
which ignores networked file systems, virtual file systems etc. (see Debian’s configuration file for example; this is standard practice in Debian, so GNU’supdatedb
is configured similarly).