Library.db size more than doubled in latest version

For those looking for the scripts:


To add to OttoKerner’s comments…

Reiterating that the debloat script is much faster than letting PMS perform the process.

When using the debloat script, Plex Media Server is shutdown and the database is closed. This lets the script take actions and use SQLite commands that are not possible when Plex Media Server is running and the database is open.

Another advantage of the script is that it does not require as much free space to debloat the database. As long as the drive/partition is not completely full, the script generally has room to work. When Plex Media Server is cleaning the library it requires as much empty space as the bloated database. During the process, the -wal db file grows to the size of the bloated database before the main db is reduced in size. If the space is not available, then the process will fail.


Regarding letting PMS clean the database:

Plex Media Server will clean the database if these conditions are met:

  • Optimize database every week is enabled in Settings → Scheduled Tasks
  • The maintenance window is wide enough for Plex to reach the Optimize Database task in the time allowed (once the task starts it will run to completion even if the window closes)
  • Enough space exists on the drive/partition holding the database files. Slightly more than the size of the bloated database is required. If needed, relocate or delete database backups to clear space.

It will take much longer than the debloat script, and Plex Media Server will be non-responsive during the cleaning process (no streaming, clients will time out trying to connect, etc.).

The Database Optimization scheduled task can be initiated immediately instead of waiting for it to run once per week.

To initiate via a POST or curl command, see Library.db size more than doubled in latest version - #302 by drzoidberg33.

To initiate using WebTools-NG, see Library.db size more than doubled in latest version - #286 by FordGuy61.

3 Likes