mlocate - what is it good for?

Brian Murray brian at canonical.com
Fri May 31 16:47:30 UTC 2019


On Thu, May 23, 2019 at 03:33:25PM -0700, Steve Langasek wrote:
> On Thu, May 23, 2019 at 08:25:20PM +0200, Sebastien Bacher wrote:
> > Le 22/05/2019 à 21:47, Julian Andres Klode a écrit :
> > > containing about 1435134 files. mlocate foo takes 1s, find / -mount
> > > -name '*foo*' takes about 7-9 secs, or 19 seconds with all mount points 
> > > (but there is a davfs mount of an internet server, so things might be
> 
> > Well here on a few years old 80GB intel ssd doing
> 
> > $ time find / -mount -name disco-desktop-amd64.iso
> 
> > Takes over 30 seconds (on a machine which not doing any other work)
> > where mlocate takes around 1 second on the same machine... and I do
> > personally find 30 seconds to be too long.
> 
> I agree that 30 seconds is too long, but as a user of find I find this usage
> surprising, why would you be searching the whole root disk for the file?  I
> usually know a file like that is going to be in one of a few subtrees (my
> homedir or /tmp or /var/lib/libvirt or something) and would be doing a more
> targeted search.
> 
> Also since the locate database is only updated once a day, locate doesn't
> help with this if the file I've lost is one I've downloaded today, and it
> seems likely to me that files I'm looking for that aren't part of the system
> data are fairly likely to fall into this category.
> 
> Anyway, agreed that 30s is too long.  Would you be annoyed if the solution
> to that 30s being too long was "get tired of waiting, run 'locate', get told
> it's not installed, apt install mlocate, run 'locate' again"?

Its worth noting that there is a step missing here - you also need to
run updatedb after installing mlocate and that isn't obvious.

Setting up mlocate (0.26-2ubuntu3.1) ...
update-alternatives: using /usr/bin/mlocate to provide /usr/bin/locate (locate) in auto mode
(disco-amd64)root at impulse:/tmp# locate ubuntu.py
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory

If mlocate were to be removed from the standard installation then we
should improve this situation.

--
Brian Murray



More information about the ubuntu-devel mailing list