Library.db size more than doubled in latest version

Definitely free up some space. The process will fail otherwise.

Hard to say how to set the scheduled tasks window. Plex may have tried to fix the database and failed due to lack of space.

If it does not impact using the server, set a wide window, something like 12 hours or more. Once Plex starts the task it will run to completion.

WebTools-NG gives you more control, in that you can choose when to start the process.

1 Like

Got it - I scraped away at the hard drive and managed to free up another 20 GB so hopefully that’s the space it needs. And I increased the scheduled tasks window, it now runs from midnight until 11 PM, so that…should be enough. Once I confirm the bloat is gone I’ll change it back to dead of night only!

Now I’ll wait another week or two and see if it fixes itself (it’s too bad there’s no way to know what day of the week it’ll do weekly maintenance on…unless there’s something I’m missing?).

Oh and a side note, about the database back-ups (i.e., the ones with dates on them) - I have several of those files, with just four different dates across them: May 12, May 15, May 18, and May 21 of this year. And I have the setting checked off to “Backup database every three days” so the interval of those dates makes sense. But since it stops at May 21 - does that mean it’s not backing itself up? Is it possible that it was around the 21st that the bloat began, or got so out of hand that it got in the way of things working right?

That’s cutting it close. Would be better if you can free up additional space, just to be safe.

During the process, the -wal file will grow to the size of the bloated db file, so you need enough room for both. If it is also the boot drive, then you’ll need whatever working room the OS needs.

Once the process is finished, the db file will be back to normal and the -wal file will still be bloated. Stop Plex Media Server and the -wal file should go away. When you re-start PMS, the -wal file will return at its normal size.

I do not know of a way to tell when the weekly database optimization will run.

That’s the advantage of using WebTools-NG - you get to say when it starts.

Plex has not backed up the db since May 21.

The bloat problem started with the 1.41.7 beta releases, so whenever you loaded one of the affected releases is when the bloat began.

Given the dates, the problem was probably bad enough by May 24 that the backup failed.

2 Likes

I’ll have to poke around to see where else I might be able to free up space (it’s not a big hard drive, only 250 GB, and I don’t use this PC for anything but Plex, so I can’t find much else “extra” to remove).

Speaking of back-ups - today I checked and it has made a back-up of my bloated DB today (“com.plexapp.plugins.library.db-2025-07-26”), which is also 85GB, so I have about 7 GB of free space. Not sure if that’s also expected as part of this process? I think this may have been said but I forget - there’s no problem with me moving those back-up DBs to e.g. my great big external hard drive temporarily to free up space right? That’s get me some more breathing room…

And I think I’ll turn off the “Backup database every three days” setting for now, at least until this is all solved, so that it doesn’t keep making massive back ups…

And I should say, I haven’t done WebTools-NG yet, only because I haven’t had the time. Maybe later this week I’ll be able to sit and just get it done!

Definitely move the backup dbs somewhere else if possible. They’re just backups. Plex does not use them.

Turning off the backup every three days is a good idea.

What OS/setup are you running on the Plex Media Server - Win/Mac/Linux/Docker?

The deflate.sh script is a lot faster than letting PMS remove the bloat - minutes versus hours. PMS is stopped while it runs. This lets it clean things up faster than PMS can by itself. Also, you don’t need as much free space.

I or someone else on the forum could lead you through it if you’re not comfortable running it yourself.

1 Like

I think it’s NOT a good idea.

Only until the db bloat problem is fixed. Then re-enable. The space is needed for Plex to de-bloat the database.

1 Like

None of the other stuff worked for me. I even tried forcing a optimize database from troubleshooting menu in the webUI. But this script worked great. Heads up, it does all the IO was through the “Plex media server” process and i didn’t even see any through the plex sql process. This was alarming for me, but appears to be normal. I had a 55GB database on a crucial SSD, this script ran over 2 hours but WORKED. Heads up, it appears to have read through all the data, and even at 7,000IOPS, this took 2-3 hours.

I ended up with a 400MB database. Make sure you save a copy of your database and blob database if you can.

Just came here to say that I found this totally by accident - I wasnt even aware of the bloat issue until I by chance saw a post on Reddit and started doing some digging (Im not so familiar with usual Plex DB sizes. Assumed 30gb+ was reasonable)

But thank you @ChuckPa , this just reduced my 37GB to 177mb!
Now running DBRepair on Auto to complete the process :slight_smile:

Do you have any idea how long it might take?

As far as I’m concerned, the script has been running for 12 hours now, and apart from seeing that it’s working on the files, I don’t have the impression that much is happening.
I’m running Windows Server and the database is on an SSD.

167 GB database

Even if it is going to run for 3days, this will still be shorter than recreating your Plex libraries from scratch. At least if you have been using it for more than a few months.

I’ve been on Plex for almost 20 years now :innocent:

5 posts were split to a new topic: No bandwidth statistics stored

Maybe you want to put in an exception in the settings of your anti virus software, for the plex data folder.
Some A/V sofctware can really slow down things, or keeping a lock on certain files for too long until the app which needs it throws an error.

1 Like

I had already set an exception for the entire Plex folder. and I can see that it is working on the DB files, but apart from the com.plexapp.plugins.library.db-shm file, which is now 1312 KB, I can’t see anything else.
I hope it doesn’t go up to 500MB, otherwise I’ll have to wait over a year.:rofl:

Yesterday morning I got to watch my system as Plex attempted to Optimize Database as a weekly scheduled task, during which it was, I assume, attempting to fix my DB bloat issue (my DB is 85 GB!). However, as mentioned here, for this process to work I need a comfortable amount of free space on my hard drive for Plex to do its thing (i.e., at least 85 GB, plus more for breathing room…I’m guessing 100 GB of free space would do the trick?).

But this is where I am at a loss and could use some advice and guidance. When I look in Windows Explorer to see how much total space is available on my hard drive, it says 222 GB. Currently, on a day-to-day basis, I am using 144 GB of that space. The biggest hogs are:

  • Plex Media Server - 106 GB, which includes:
    • Plex DB - 85 GB
    • Plex DB-WAL - 12 to 15 GB (this was at 0 GB when I first peeked into my system this morning, but then climbed and climbed until the Optimization process crapped out when it ran out of hard drive space)
  • Windows files - 25 GB
  • Program files - 7 GB

I’ve uninstalled all the programs I can. I don’t think I can delete much if anything in the Windows files, can I? (I’ve done the Windows Disk Cleanup thing to remove unneeded Windows Update files.) I’ve done defragging… I feel like the bloat issue has painted me into a corner - my hard drive isn’t huge but it’s more than big enough for what it’s meant to do (run Plex). But it’s not big enough for Plex to do what it needs to do to fix its own issue…

I did go ahead and download Web Tools-NG and I have that queued up and ready to go to manually run the Optimize Database process as soon as I’m ready. But I just can’t figure out any way to free up enough hard drive space (short of buying a bigger hard drive, but that’s a pretty big out-of-pocket expense to pay, solely to fix a Plex bug).

I do have a great big external hard drive with over a TB of free space (that’s what I use to save all my actual media files). Perhaps there’s a way to temporarily transfer something over there? I feel it’d be extreme to completely move/reinstall my whole Plex Server over there, fix the DB bloat, then move/reinstall it back on my hard drive…but is that an (only) option?

UPDATE - before I posted, I thought I would try the “Compress this drive to save disk space” option as a last resort. I don’t think I want/need that permanently, but it did give me 111 GB of free space, which I thought would be enough. I used Web Tools-NG to run the Optimize Database task yesterday around 1PM, which left Plex unresponsive until bedtime (which was expected), but when I woke up this morning the DB was still at 85 GB. “Compress this drive to save disk space” would have also compressed the Plex DB, not sure if that would cause an issue? Or maybe there’s some other step I’m missing? I’ll wait until late this evening to try again and run Optimize Database again, overnight…I’ll see what happens…

Copy the database folder over there. Put it into the same folder structure that it has on your C: drive.
Then pretend to have moved all the other data of your plex data folder as well and make the registry change as explained in [HowTo] An extended guide on how to move the Plex data folder on Windows
But never start Plex server with that registry change in place.
Instead, just use the debloat batch file from above, followed by the repair bat file from DBRepair/Windows at master · ChuckPa/DBRepair · GitHub
Once that is done, copy the de-bloated and repaired database files back to their original place on C:, overwriting the bloated ones.
Then remove the new registry key again.
Only then start Plex server.