Edit:
I ran a test with my Windows desktop.
PMS 1.41.8.9834 cleaned the database when running Optimize Database as a scheduled task. Manually initiating a database optimization via Settings → Troubleshooting did not do so.
While the process is running, the Activity icon in Plex Web shows that a database optimization is underway.
When complete, the database file is returned to its normal size, and the -wal file is roughly the size of the db file when it was bloated.
Stop PMS to remove the -wal file (this is normal, bloated or not). Then re-start PMS.
According to Settings → Library, Plex will optimize the database once per week.
If desired, you can start the process early by using WebTools-NG
In the Butler Scheduled Tasks section, select the Optimize Database task. This starts the same database optimization process as if you waited for PMS to run the task.
PMS will be non-responsive while the optimization is underway and assume it may take hours to complete, so time things accordingly.
FWIW, it took almost an hour to reduce a ~30GB db to ~200MB on my PC with the OS & Plex Data Folder on an SSD. The process would take longer if the db was on a hard drive.


