What is mdworker_shared on a Mac, and why are there so many?

mdworker_shared is part of Spotlight. Each copy opens files that are new or changed, reads what is inside them, and hands the text to Spotlight’s index so you can search for it later. Seeing a handful of them at once is normal, and they come and go by themselves. You do not need to end them, and ending them only makes the work start again.

The name looks alarming because it is a bare program name with an underscore, and because it can appear six, eight or more times in a list of processes. Both things have a plain explanation.

What mdworker_shared does

Spotlight is more than the search window. It keeps an index, a kind of catalogue of your files: names, dates, and for many file types the words inside them. When you type a few words into Spotlight, macOS looks in that catalogue instead of reading every file on the disk.

Something has to fill the catalogue, and reading files is risky work. A damaged PDF, a huge spreadsheet or an odd video file can trip up the code that reads it. So Spotlight does not read files inside its main process. It starts separate helper programs for the job, and mdworker_shared is the name of those helpers. If one of them chokes on a bad file, only that helper is affected and Spotlight carries on.

The helpers are managed by mds, which Foreman calls the Spotlight index server, and the results are written by mds_stores. If you want the full picture of the index itself, What is mds_stores on a Mac? Spotlight indexing explained covers the part that does the writing.

Why there are so many copies

Spotlight does not read files one at a time. When many files change at once, it starts several helpers so the work goes faster, and each one takes a batch. When the batch is done, the helper exits. That is why the number in a list changes from minute to minute: you are looking at a crew that grows when there is work and shrinks when there is not.

You will see more of them after:

  • a macOS update, because the index is often refreshed afterwards (see Why is my Mac slow after a macOS update?)
  • copying a large folder, restoring from a backup or unpacking a big archive
  • connecting a drive full of files that Spotlight has not seen yet
  • a first start on a new Mac, or after a user account is set up

On a quiet Mac, with nothing new to read, you may see none for hours. That is also normal.

When it is normal and when it is not

Normal looks like this: several copies, each using some processor time, for a few minutes up to an hour or so after one of the events above, on a Mac whose fans and battery are otherwise behaving. After a large change, like restoring a whole home folder, it can take longer, because there is more to read. A Mac with a great many small files takes longer than one with a few big files.

Worth a closer look: the same copies busy for many hours or days with no big change to explain it. Then the usual causes are:

  • A folder that changes constantly. A project folder with thousands of files that a build tool rewrites every few seconds gives Spotlight new work all day.
  • A folder Spotlight does not need. Virtual machine disks, large caches, downloaded datasets and old archives are rarely things you search by their contents.
  • An index that is stuck. Rare, and the answer is in the Spotlight steps below.

What to do about it

Start with nothing. Leave the Mac on and plugged in, and let it finish. Spotlight’s indexing is designed to be done in the background, and it is the reason search is fast afterwards. Interrupting it does not save work: the index is still incomplete, so the helpers start again later.

If it keeps going and you want it to stop reading certain places, tell Spotlight to leave them out. In System Settings, open Spotlight and click Search Privacy (on macOS 14 Sonoma, open Siri & Spotlight and click Spotlight Privacy). Add the folders you never search, such as a folder of build output or a disk full of video files, and Spotlight will stop indexing them. The trade-off is that their contents will no longer turn up in Spotlight searches.

Check one more thing before you blame Spotlight: whether a particular app is making the changes. If a sync app, a backup tool or a build keeps rewriting a folder, the real fix is to change what that app does. How to find out what’s running in the background on your Mac shows how to spot it.

You may see advice to run mdutil in Terminal. It is Apple’s tool for managing Spotlight indexes, and several of its options turn indexing off or erase the index. Leave it alone unless you are following Apple’s own instructions and know what each option does.

Seeing them in Foreman

If you want to watch what these helpers are doing, Foreman groups them. On the Processes page, copies of one background program share a single row with a count, so mdworker_shared appears as one row such as “Spotlight file reader (4)”, with the real name beside it in grey. The row adds the copies up, so the CPU and Memory columns show the whole crew at once instead of eight rows you would have to add in your head. Click the CPU column to sort, and the row climbs to the top while Spotlight is busy and drops away when it finishes.

That tells you quickly whether Spotlight is the cause of a slow patch or whether something else is. If the reader row is quiet and the Mac is still slow, you can stop suspecting Spotlight and look at the apps at the top of the list instead.

Foreman describes the row in one line: it reads new and changed files so Spotlight can search them. It does not clear the index or change what Spotlight covers, so folder exclusions are still done in System Settings.

Should you end mdworker_shared

You can, but there is little reason to. The helpers are part of macOS, and macOS starts new ones when it needs them, so ending one is a pause at most. If a single copy has been running at full tilt for hours on one file, it may be stuck on a file it cannot read, and ending that one copy lets the others carry on. Ending them all just wastes the progress they made.

If you see it growing in memory or processor use over many hours, with the Mac otherwise idle, a restart gives Spotlight a clean start. That is a reasonable first move before anything more drastic.

Quick answers

  • Is it a virus? No. It is part of macOS. The name is a program name, not a threat.
  • Why more than one? Spotlight splits the work across helpers so it finishes sooner.
  • Why now? Something changed: an update, a big copy, a new drive.
  • Will it stop? Yes, once the new files are read.
  • Can I turn it off? Exclude folders in the Spotlight settings; do not try to remove the process.

Foreman is $12 once, works on up to 3 Macs and is free for 24 hours, so you can look at your own Spotlight row before deciding. The steps above do not need it.