Debugging Windows Search Issues and High CPU Usageβš‘

Contentsβš‘

Diagnosing and Repairing High CPU Usageβš‘

Restart the Windows Search Serviceβš‘

To get a listing of all available services, both running and stopped run Get-Service:

Can disable the service through services.msc or using powershell:

# diable the service:
Set-Service -Name "WSearch" -Status stopped -StartupType disabled

# re-enable automatic startup
Set-Service -Name "WSearch" -StartupType automatic

# reboot system

Alternatively, use Command Prompt - CMD:

Get a list of all running services:

sc queryex state=all type=service

Restart services using net stop and start services with net start:

net stop "WSearch"

net start "WSearch"

Alternatively, you can use the more advanced sc command:

# start / stop
sc stop "WSearch"
sc start "WSearch"

# various startup options:
sc config "WSearch" start=disabled
sc config "WSearch" start=auto
sc config "WSearch" start=demand
sc config "WSearch" start=delayed-auto

Run the Search Diagnostic Troubleshooterβš‘

msdt.exe -ep SystemSettings_Troubleshoot_L2 -id SearchDiagnostic

If necessary, the troubleshooter fixes the NTFS permissions for the Windows Search data folder so that the NT AUTHORITY\SYSTEM account has the required permissions. By default, the search data folder is located at %ProgramData%\Microsoft\Search\Data\. The troubleshooter can also reset the Windows Search settings and force a rebuild of the Search index if deemed necessary.

Manually Reset Windows Search and Rebuild the Indexβš‘

The Search troubleshooter is the most preferred way to troubleshoot search and indexing issues, as it automates many things (depending upon the checkbox options you selected).

However, if you want to manually reset Windows Search, delete and rebuild the index, use these steps:

Reset via Registryβš‘
  1. Start the Registry Editor regedit.exe and go to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search
  2. Change the registry value SetupCompletedSuccessfully data from 1 to 0.
  3. Exit the Registry Editor.
  4. Open the Services MMC (services.msc)
  5. Restart the Windows Search service
Reset Service and Rebuild via Batch Fileβš‘
sc config wsearch start= disabled
net stop wsearch
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Search" /v SetupCompletedSuccessfully /t REG_DWORD /d 0 /f
del "%ProgramData%\Microsoft\Search\Data\Applications\Windows\Windows.edb"
:wsearch
sc config wsearch start= delayed-auto
net start wsearch
IF NOT %ERRORLEVEL%==0 (goto :wsearch) ELSE goto :END
:END
Rebuild without Resetting via Batch Fileβš‘
sc config wsearch start= disabled
net stop wsearch
del "%ProgramData%\Microsoft\Search\Data\Applications\Windows\Windows.edb"
:wsearch
sc config wsearch start= delayed-auto
net start wsearch
IF NOT %ERRORLEVEL%==0 (goto :wsearch) ELSE goto :END
:END

Defrag the Search index database Windows.edb to reduce the file sizeβš‘

If you index too many files & folders and the Outlook PST files, the Windows search index database file Windows.edb would grow huge in size. In some instances, the file size can be larger than 50 GB. That’s because, in Windows 8 and Windows 10, both properties and persistent indexes are stored in Windows.edb. Also, Windows 8, Windows 8.1 and Windows 10 index the entire contents of files, regardless of their size.

To reduce the Windows search index database size, index less content. Another option to reduce the size of Windows.edb is to compact or defrag the file using esentutl.exe1. Follow these steps:

Open an admin Command Prompt window, and run these commands:

sc config wsearch start= disabled
net stop wsearch
esentUtl.exe /d "$env:allusersprofile\Microsoft\Search\Data\Applications\Windows\Windows.edb"
sc config wsearch start= delayed-auto
net start wsearch

The above commands stop/disable Windows Search, compact (defrag) the search index database, and then start Windows Search. Compaction of the Windows.edb database has reduced the size to 200 MB from 310 MB on my computer β€” ~30% savings.

Resetting the Search index, or removing unwanted folder locations from the search index, and compacting the database would certainly improve the search performance in your system.

Notesβš‘


Links: WindowsDevEnv | Computer-Setup | Windows Command Line Commands Overview

Sources: