Library.db size more than doubled in latest version

I would like a definite answer for this as well. Lots of things can happen to those folders. What if you restore an old database backup file? Now you have tons of orphaned files in those folders that aren’t connected to any database record.

Why would you do that? AI is just a “parrot”. It repeats what it read somewhere else – without the ability to check these statements for correctness. You could be looking at misconceptions that other Plex users wrote someplace on the Internet and take them for proven fact. Just because some AI tool is blurting them.

No, I already explained above that “Cleaning Bundles” is explicitly to find unused bundles. That is bundles which have no counterpart in the Plex database. Which means removed media.

2 Likes

I’m just reading the links you sent me and your previous response that didn’t fully answer the question and left it open ended - imo.

CoPilot was very specific and after a few more questions, it referred me to an app to remove Plex orphaned files and seemingly, any files which don’t have entries in Plex.

Link?

Unused bundles that were purged/deleted from the database? It does not appear that files data files created after the backup will be removed by cleaning Bundles.
Those files will need to be removed manually.
You, yourself said “pretty much all” - it either removes the files, or doesn’t remove them.
I error on the side of caution and the facts as stated.

You lost me there.

In my example I backed up.
I added 1500 videos.
Several days later “Plex crashed” and I restore the backup.
Plex is unaware I added 1500 videos so it will find them all over again, however, from what I’ve read, Cleaning Bundles will not find and remove the data from the 1500 videos - thumbnails, posters, backgrounds, voice statistics, and credits detection…
The way I understand this, those files will remain after the cleaning and deleting process.

From CoPilot::

The plex-find-orphaned tool and Plex’s Clean Bundles function serve different purposes when managing metadata and unused files:

  • Plex Clean Bundles: This is an official Plex feature that removes unused metadata and image files associated with deleted media. It runs as a scheduled task or can be manually triggered through Plex settings43dcd9a7-70db-4a1f-b0ae-981daa162054. However, it only cleans up files that Plex recognizes as outdated, meaning it won’t detect orphaned files left behind due to database inconsistencies.

  • plex-find-orphaned: This is a third-party tool that scans your Plex directories for files that are no longer referenced in the Plex database. It identifies orphaned metadata, thumbnails, and cache files that Plex’s built-in cleanup might miss. This tool is useful for deeper cleanup, especially after restoring an older database or manually removing media.

Essentially, Plex’s Clean Bundles is a routine maintenance tool, while plex-find-orphaned provides a more thorough scan for lingering files that Plex doesn’t automatically remove. If you’re dealing with orphaned files after a database restore, the GitHub tool might be the better option! Let me know if you need help setting it up.

I’m, not even sure that this is for cleaning up the plex data folder. From its description it sounds more like it will find media files which haven’t been picked up by Plex’s scanners.

That was a follow-up question to compare the two methods of file cleanup.

Over the two topics, CoPilot have me pages and pages of descriptions detailing every step and process.

It might be wrong, but I’m sure it has collected more information on Plex and its functions than after provided on the help/FAQ pages.

Plex really needs to come out with actual documentation. :face_with_diagonal_mouth:

And still it lacks the ability to reason and draw correct conclusions from this wealth of information.
I stand by my opinion that it has presented you with wrong information. And the external tool it has linked does not what you think it does.

3 Likes

I was nervous to roll back and lose any changes since the last backup.
My db file had grown from 500 MB to 14 GB!
Thank you for these commands. Everything is back to normal now.
For anyone else, it can take a long time, just let it run.

The next beta version (1.41.8) will have a fixup that removes the excess database rows during the scheduled maintenance hours - if anyone isn’t comfortable running these commands manually.

11 Likes

Relying on Co-Pilot to compile some info seems fine but relying on it over a conversation with Plex folks directly might be giving it too much weight. And debating about what is or isn’t right statements on both sides might be distracting.

The basic question, is, I think:

“If I restore a backup of the DB after adding\removing titles between the most recent version and the backup, what cleans up all the supporting references and resources still around in the Plex Media Server folder from those titles?”

That is outside of this specific DB size fix drzoidberg33 said will be in the next beta.

That’s why I stopped praying about it.
I would have stopped earlier if he could explain how Plex decides what to delete in the folders.

But it is related because people on this post have suggested going back to a backup because it’s not known if Plex will be able to remove the extra, many gigabyte’s, of extra data. :face_with_diagonal_mouth:

The “backup” recommended above was primarily referring to a DB file backup. i.e. those that PMS is creating itself.
Not so much a backup of the whole plex data folder, created with an external tool.

1 Like

Looks like PMS 1.41.7.9799 was rushed out of beta. Plex Media Server - #676 by chris_decker08

  1. I assume 1.41.7.9799 doesn’t have the problem of increasing DB size.
  2. The fix (for those previously affected) that deletes SQL records will be in the next version: 1.41.8.0

1.41.7.9799 isn’t increasing for me

If this helps anyone else, I was having a hard time with the linuxserver.io image container shell on TrueNAS Scale

#Login to Container from TrueNAS Scane use /bin/bash
#Down Service
s6-svc -wd /var/run/service/svc-plex
#Go to Database Directory if you want, you can ls -alh and see the database size and also see the previous sizes based on the backups
cd '/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases'

#Run the SQLLite Utility, it will open sqlite> prompt
/usr/lib/plexmediaserver/Plex\ SQLite 

#Open the Database
#If you want to back it up then you're on your own. 
#The Delete statement took over 30 minutes on a 41GB database, it returned it to below 300MB
./open '/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db'

DELETE FROM statistics_bandwidth WHERE account_id IS NULL;
VACUUM;

#CTRL-D to exit

#Up Service
s6-svc -u /var/run/service/svc-plex

2 Likes

Can anyone tell me specifically what this below actually does?

DELETE FROM statistics_bandwidth WHERE account_id IS NULL;
VACUUM;