Library.db size more than doubled in latest version

OK. Is there any way to know when it’s completed? Or if it’s just gotten stuck? It’s a pretty well resourced system but Plex is pretty bloated, stuck at around 92GB

I had the same question, and ChuckPa would ask Engineering today. I suspect we’ll have an answer by tomorrow if waiting will eventually solve the problem. (My database inflated from 430MB to 58GB.

Currently, my Plex runs fine with the bigger database, but the automatic backups are failing

Hi @ChuckPa I would appreciate some help with this… I am attempting to setup your script above as a .sh script and run it on the Docker Bash.

I have set:

DBDIR=“/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases”

but I am getting:

root@PMS:/# bash Script.sh
Script.sh: line 2: $‘\r’: command not found
Script.sh: line 8: $‘\r’: command not found
Script.sh: line 9: $‘\r’: command not found
Script.sh: line 12: $‘\r’: command not found
Script.sh: line 16: $‘\r’: command not found
'RROR: No such directory '/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases
: numeric argument required

Thanks in advance, I have a 90GB database to fix :zany_face:

@John-Piper

You’re using Windows, did a copy/paste into “NotePad”, didn’t you? :slight_smile:

Windows adds CR+LF for each line (makes no sense anymore)
Linux only uses LF

Let me make a tar.gz for this so it can safely be downloaded on windows then transferred to the Linux box.

For those using Windows to download/upload to Linux boxen.

ChuckPa-Deflate.tar (10 KB)

  1. Download this .tar
  2. Upload it to the Linux box where you can run it via the command line
  3. tar xf ChuckPa-Deflate.tar
  4. chmod +x ChuckPa-Deflate.sh
  5. Edit the file using a LINUX text editor (nano, ed , vi, etc)
    – Edit PSQL to point to where Plex SQLite is (not sqlite3)
    – Edit DBDIR to point to where the Databases are
    – SAVE
  6. sudo ./ChuckPa-Deflate.sh

This will fix a 90 GB DB but unfortunately can’t help you with the :zany_face:

1 Like

@ChuckPa didn’t want to start an entire thread for just this one question so i figured i’d post it here which is kinda of but kinda of not off topic.

I’m currently on 1.41.3.9314. I lag in updates to avoid having the very issues that generated this current thread. Do you think it is safe to upgrade to 1.41.8.9834 or are a lot of material kinks still being worked out like this bloating DB issue?

I have no need to update at this time. I just like to stay behind but not too far behind because that also can end up with issues when you eventually upgrade! Thanks for any advice.

@djfriday13

If you never installed any variant of PMS 1.41.7 then your DB Is safe from the bloat problem.

Installing 1.41.8 should be free of the issue .

1 Like

Perfect, ran for only 5 minutes or so… Debloated from ~90GB to 96.2mb :smiley: Far more reasonable! Thanks @ChuckPa for your help!

1 Like

Thanks for the script! I ended up running it line by line because running script from within the docker somehow gave no output at all (maybe the tar would’ve worked I didn’t try that one).
Went from 274GB to 100MB. It took me about 25minutes but obviously running line by line is slower than the script would be. Definitely 100% better than whatever optimize scheduled task was doing (taking plex down and no response even after a day, couldn’t fix it that way)

1 Like

For those who are more Windows-savvy and want to manually set pathnames.
( I don’t know them )

Here is the ZIP version for you.

You’ll need to edit, set pathnames, and make certain the AI did a proper BAT file.

ChuckPa-Deflate-WINDOWS.zip (1.6 KB)

ALL:

When Plex SQLite runs, there is no ‘progress bar’. It silently does its work.

It doesn’t know how much it has to do so it can’t give any completion percentages.

This night, Plex performed it’s maintenance, but this morning, Plex is unresponsive. On the background, unraid reports plex as unhealhy.

docker.img reports an extra 49 GB in use.

The following files are still getting modified:

  • com.plexapp.plugins.library.db-wal (57GB)
  • com.plexapp.plugins.library.db-shm (195MB)

During the previous database optimize attempt I manually started, the files kept getting modified until around 24 hours and then no further changes where detected.

I fear this will run into the same stalling issue as last time …

@ChuckPa , any feedback from the engineering team on why the database inflated? As I only run official releases, I suspect more users could be affected?

1 Like

I couldn’t wait anymore and wanted my plex server back online so I restarted the docker container. (The db-shm file ended up beïng 303 MB and still growing slowly).

During restart, I checked the unraid logs for Plex an noticed Plex updating to 1.41.9.9912 and Unraid reporting plex unhealty again so I suspect Plex is again trying to optimize the libary, again?

This time, only the db-shm file is growing at a steady pace (currently 146MB) so I’ll give it some time and hope it wrestles through :crossed_fingers:

s6-svwait: fatal: timed out
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 79.3M  100 79.3M    0     0  29.0M      0  0:00:02  0:00:02 --:--:-- 31.8M
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 40-plex-first-run: executing... 
[cont-init.d] 40-plex-first-run: exited 0.
[cont-init.d] 45-plex-hw-transcode-and-connected-tuner: executing... 
[cont-init.d] 45-plex-hw-transcode-and-connected-tuner: exited 0.
[cont-init.d] 50-plex-update: executing... 
Attempting to upgrade to: 1.41.9.9912-371133ff9
(Reading database ... 10012 files and directories currently installed.)
Preparing to unpack /tmp/plexmediaserver.deb ...
PlexMediaServer install: Pre-installation Validation.
PlexMediaServer install: Custom environment detected.  Skipping preinstallation validation.
Unpacking plexmediaserver (1.41.9.9912-371133ff9) over (1.41.8.9834-071366d65) ...
Setting up plexmediaserver (1.41.9.9912-371133ff9) ...
PlexMediaServer install: Custom environment detected.  Skipping postinstallation tasks. Continuing.
[cont-init.d] 50-plex-update: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Starting Plex Media Server.

Update
Plex is back online, the database is still massive:

@Klaas_Ann-Sophie

Have you considered doing a manual cleaning/fixing of the DB ?

Yes, but I want to reserve some time for that to fully concentrate to avoid making mistakes so that is a job for this weekend :slight_smile:

Is the script different form what Plex is doing with the optimization?

Sidenote: I’m using the docker plexinc/pms-docker:plexpass and the setting Server update Channel is set to Public but it seems that I’m running the latest Beta?

I don’t know why it’s pulling beta versus public but you can specify which version-build you want the container to use. (which I always do)

( did you specify ‘latest’ and have your account settings for ‘beta’ channel ? )

If you wish help , I’ll show you / help you perform the deflate.

The Plex docker image gives us the ability to stop PMS without stopping the container — which is perfect for what we need to do with the DB.

1 Like

Good point, I need to stop PMS but not the docker container but I have no clue how to do that.
So the current plan seems:

  • Copy/Extract the script in a folder accessable to the docker container (somewhere in the plex config folder)
  • Stopping the Plex Service
  • Running the script
  • verifying the new size
  • Starting Plex back up (or do a complete plex docker reboot)

My current unraid settings for the docker:

And my settings inside plex:

To control PMS inside the container, we leverage s6-supervise.

root@Gerbil:/var/lib/docker# docker container list
CONTAINER ID   IMAGE                COMMAND   CREATED        STATUS                  PORTS     NAMES
2fc77f417719   plexinc/pms-docker   "/init"   23 hours ago   Up 23 hours (healthy)             Plex-Media-Server
root@Gerbil:/var/lib/docker# docker exec -it Plex-Media-Server bash
root@Gerbil:/# ls /
bin	data  glock	      init		lib32	 libx32  opt		  proc	sbin  tmp	 var
boot	dev   healthcheck.sh  installBinary.sh	lib64	 media	 plex-common.sh   root	srv   transcode  version.txt
config	etc   home	      lib		libexec  mnt	 plex_service.sh  run	sys   usr
root@Gerbil:/# /plex_service.sh -d
root@Gerbil:/# ps -ef | grep -i plex
root         309       1  0 Jun26 ?        00:00:00 s6-supervise plex
root      152257  152192  0 11:12 pts/0    00:00:00 grep -i plex
root@Gerbil:/# 

-d = Down
-u = Up

Now for the paths -

root@Gerbil:/# ls -la  /usr/lib/plexmediaserver/Plex\ SQLite 
-rwxr-xr-x 1 root root 11152 May 27 09:26 '/usr/lib/plexmediaserver/Plex SQLite'
root@Gerbil:/# ls -ls /config/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/
total 626940
     4 -rw-r--r-- 1 root root       1726 Jun  5 22:13 DBRepair.log
  1108 -rw-r--r-- 1 plex users   1134592 Jun 27 11:12 com.plexapp.plugins.library.blobs.db
  1108 -rw-r--r-- 1 plex users   1134592 Jun 14 02:03 com.plexapp.plugins.library.blobs.db-2025-06-14
  1108 -rw-r--r-- 1 plex users   1134592 Jun 17 02:03 com.plexapp.plugins.library.blobs.db-2025-06-17
  1108 -rw-r--r-- 1 plex users   1134592 Jun 20 02:04 com.plexapp.plugins.library.blobs.db-2025-06-20
  1108 -rw-r--r-- 1 plex users   1134592 Jun 23 02:04 com.plexapp.plugins.library.blobs.db-2025-06-23
127500 -rw-r--r-- 1 plex users 130555904 Jun 27 11:12 com.plexapp.plugins.library.db
121436 -rw-r--r-- 1 plex users 124350464 Jun 14 02:03 com.plexapp.plugins.library.db-2025-06-14
123580 -rw-r--r-- 1 plex users 126545920 Jun 17 02:03 com.plexapp.plugins.library.db-2025-06-17
123312 -rw-r--r-- 1 plex users 126271488 Jun 20 02:04 com.plexapp.plugins.library.db-2025-06-20
125564 -rw-r--r-- 1 plex users 128577536 Jun 23 02:04 com.plexapp.plugins.library.db-2025-06-23
     4 -rwxr-xr-x 1 root root        502 Jun 12 10:41 do-deflate
root@Gerbil:/#
1 Like

In unraid, you have an easy way to achieve docker exec through the docker menu >_ Console.


(Plex is still running)

I think I have all the information and report back this weekend.

You’re right – I forgot that. ( as I look at my unraid machine :man_facepalming: )

The :plexpass tag was deprecated 4 years ago. It automatically installs the beta version.

https://hub.docker.com/r/plexinc/pms-docker/tags?name=plexpass

The “Server update channel” setting is irrelevant for the docker container. The installed version is dictated by the docker image tag. See the latest readme for the available tags.


Side note: the readme on dockerhub is out-of-date and refers to the old tags. @ChuckPa you should poke someone to fix this.

https://hub.docker.com/r/plexinc/pms-docker#:~:text=your%20own%20user.-,Tags,-In%20addition%20to

1 Like