Library.db size more than doubled in latest version

I wanted to share my experience with this as well, but please excuse my notes as I just jotted some items down quickly last night and was playing around with this rather late. I don’t really have track of which version my bloating issue started occurring at, but I tend to keep my PMS version up to date. I recently went through a migration from Windows 10, to Docker Desktop on Windows 11 and using the official Plex PMS docker- imageplexinc/pms-docker:plexpass. I like this version as it auto updates when the container restarts.

Migrated approximately January 2025 and my DB file was already somewhere around 30GB, I think. I am a little fuzzy on this, or it could be that my whole PMS folder was around 40GB. I only partially remember while transferring everything to a new system. Right now, post fix, it is sitting at about 84GB as I’ve added quite a bit to it since migration. Decided I wanted to learn and play around in Docker so that’s the reason why running it on Windows 11 in Docker Desktop. Thinking I will go back to a dedicated machine in future.

Some library stats:
Movies: 900
Episodes: 7500
Music: 66,000

I did a couple tests last night after learning about this and also just wanted to help if there are any other Windows users as I had to hunt around a bit to figure out how to run the commands, both from within the container after having stopped PMS with the container still running, and also tested just doing the fix via Windows.

The Database repair to “delete from statistics_bandwidth where account_id is NULL;” seems to run faster natively in Windows. It took longer running in the Linux docker container shell. I’ve noticed this slowness with loading/running Lidarr as well in my docker container of Lidarr with no add-ons seems to take much longer to load than it did on my older Win10 system than running in a docker container on Win11. I have not been happy with the performance, but perhaps there are some Docker Desktop settings I need to adjust? Running the config files for both PMS and Lidarr on a Samsung 990 Pro NVMe. Running Intel Core i7 14700F with 64 GB RAM.

The tests runs took my 46 GB db file and took it to 459 MB for both tests after running
’ VACUUM; '.
The .db-wal file (temp) was 36.6 GB, deleted after exiting Plex SQLite
Windows ~1.5 hours
Docker container ~4 hours
I looked at a copy of the db prior to repair using HeidiSQL, there was 811,426,257 rows total in the statistics_bandwidth table for me.
This was reduced to 19,839 rows after running the command in this topic.

Running in the Docker Container shell (Slow method, at least for me):

  1. Shutdown PlexPMS but leave the container running
    #./plex_service.sh -d
  2. Change to your database directory
    #cd "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/"
  3. Backup your database per instructions from Plex: Repair a Corrupted Database
  4. Run Plex SQLite
    #"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db
  5. Run the command listed in this topic and wait a Million Years. :grimacing:
    sqlite> delete from statistics_bandwidth where account_id is NULL;
    fixes bloated database for this issue as stated above
  6. Vacuum
    sqlite> VACUUM;
  7. Quit
    sqlite> .quit
  8. Restart PMS
    #./plex_service.sh -u (-d for down, -u for up, -r for restart)
    or
    manually restart the container.

Running from Windows Command Prompt:
I had to download and install PMS for Windows, just to make sure I had the Plex SQLite.exe. I did also learn how to copy it out from the docker container, but I think it needed the Plex PMS .exe to run properly.

Copy files from docker container:
C:\>docker cp *container_name*:/usr/lib/plexmediaserver/ c:\temp

  1. Shutdown PlexPMS but leave the container running or just fully shut down the container as it doesn’t need to be running.
    #./plex_service.sh -d
  2. Backup your database per instructions from Plex: Repair a Corrupted Database
  3. Using Windows Command Prompt, Run Plex SQLite to open your db file (edit as needed to point to you Docker Container path in Windows)
    C:\>"C:\Program Files\Plex\Plex Media Server\Plex SQLite.exe" "C:\path\to\Docker PMS\Library\Application Support\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db"
  4. Run the command listed in this topic and wait for less time.
    sqlite> delete from statistics_bandwidth where account_id is NULL;
    fixes bloated database for this issue as stated above
  5. Vacuum
    sqlite> VACUUM;
  6. Quit
    sqlite> .quit
  7. Restart PMS
    #./plex_service.sh -u (-d for down, -u for up, -r for restart)
    or
    manually (re)start the container.

Worked for me in my situation. Things felt a bit snappier opening and navigating Plex on Desktop/phone/tv all on the network, but haven’t had any feedback from anyone else who uses my server yet. I just hope these commands help and save some time for some of you. Appreciate any thoughts or inputs. Thank you.

4 Likes