Why does MDS run wild in Mac OS X 10.6?

Solution 1:

To see what mds and more importantly its child mdworker is actually doing - use fs_usage to log what files it is opening:

sudo fs_usage -w -f filesys mdworker

Though there is a lot of unintelligable stuff in there, it does tell you when it opens a file to begin reading from it. Copying a PDF into my filesystem shows mdworker opening the file then immediately after lots of activity...

p.s. if you want a little less detail, this will just list the open file points:

sudo fs_usage -w -f filesys mdworker | egrep "open"

Solution 2:

In the rare case that you would like to disable spotlight, use the following command:

sudo mdutil -a -i off

To re-enable:

sudo mdutil -a -i on

Solution 3:

Just wanted to note that Spotlight/MDS may not be the issue at all. Errors with Time Machine (particularly where Time Machine takes a long time to "index") can create a situation where Spotlight tries to continually index the same files.