Server Version#: 1.22.3.4523
Player Version#: 4.57.2
I’ve seen a couple of Topics about this issue but I can’t tell what exactly the solution is.
My server is slow to start playing media, it feels laggy and the Console window is constantly showing that it’s updating metadata for things it’s already tagged.
Anyway, my main problem is that any time I try to Optimize the DB in Plex, it immediately kills any use of the server. Anything playing will stop, remote connections drop, if you are on the home page, nothing will be able to start playing, etc.
When this happened previously, I stopped Plex from the system try and when I check in Task Manager, everything had stopped except for Plex Media Server.exe - which was still very slowly doing something. Was it actually optimizing or just hanging? I’m not sure where to look. I have a pretty healthy library so I’m guessing it could take a while?
I used to be able to do this with no issue but I’m guess my DB is corrupted so I’m looking for a way to maybe externally repair/optimize it. I’ve seen the old topic of:
…but everywhere I’m reading now says that you must use the sqlite that is built into Plex. I can’t find a Windows versions of the instructions and I’m sure there has to be an easy way to do this…or maybe there’s a way to optimize it outside of Plex? Someone said they did it externally once and it worked but they didn’t mention how.
I was able to find some instructions that “worked” in so much as, after I ran the Restore DB commands using the PMS -sqlite format, it seemed to work.
PMS just seems so delicate right now to me. I can do everything just fine EXCEPT the Optimize DB command. It instantly kills the service. But as mentioned, when I Exit using the systray icon, everything closes except PMS.exe but I don’t know if it’s actually doing anything. I’ve let it run for a while hoping it would close when finished but it never did.
I’m happy to try Optimize again and send someone some log files, if that’ll help but this is driving me crazy.
Bump. This is still an issue for me - even though I have used the steps to fix a corrupted database several times on different days when it seems extra slow, I can’t even find documentation that says it also optimizes it when it does so.
Does anyone know?
Can we get a way to Optimize the DB from outside of Plex?
(probably not since they added their own sqlite and now you can’t do anything from outside)
My library isn’t as big as Juice’s, but yea - I used to Optimize it all the time myself and it never took that long to complete - and it didn’t kill any remote streams while it was doing it. It just started recently with the last (next to last now?) build.
Once it “crashes” every other Plex process in Task Manager except for PMS.exe, I’ve let it run for quite a while but it was taking forever and the resources never really moved.
Every now and then I would run through the Repair steps, hoping it was optimizing while doing so, but I’m not sure if it does. I do see a new command on that page now that says “The above command will reassemble your database with all the valid data it can find in your file.” Is that optimizing it? If so, I’ll try it.
UPDATE: Whoa - ok. I stopped the server and ran this command on the db from the Repair DB link with updated commands.
“C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe” com.plexapp.plugins.library.db “.output recover.out” “.recover”
After that, I shrugged and clicked Optimize…and it completed! And it only took about a minute. So - I have no idea what happened, but this seemed to work for me. So happy.
UPDATE (3 Days Later): So, on a whim, after watching several movies and shows, I decided I would give using the Optimize Database click one more shot since it ‘seemed’ to work last time. And…it DID! And, it took it about a minute or two to complete.
The old database repair steps do a really simple “dump” and “read”. It means there’s no old junk in the database files, but I don’t think it’s exactly the same as what Plex does internally for Optimize.
The SQLite .recover command is also very unlikely to do an Optimize.
Fair enough, but I ran Optimize a couple nights ago and it crashed. I ran that command and now Optimize is working as intended. It may be a coincidence but I’ll take the win.
Optimization is part of the nightly server maintenance, btw.
There is actually no need to trigger it manually, except after extensive changes like massive numbers of imports or deletions.
Yes, I had just removed a fairly large Photo library so that’s why I was trying to run it. And it’s not part of MY nightly cycle as I have that box unchecked because of crashing.
I often Move 200 items around to balance storage loading across 6HDDs.
I optimize after that.
'Cause I can.
I also Optimize - when I’m bored - 'cause I can and 'cause my Database runs on an HDD - and when I read ‘operates as quickly as possible’ I was sold. Seems to be fast enough for us - almost instant is pretty quick.
I agree that a freshly imported DB is stored efficiently on disk. There’s no empty space in the database from deleted records, etc. That’s similar to the results of a DB vacuum, which I believe Plex performs during Optimize.
Optimize also rebuilds the full-text indexes, which isn’t done by a dump/read or by .recover.
I don’t know what the other “database fix-ups” it does are.
So if it part of the nightly maintenance, then manual triggering should be very smooth instead of taking long and being unresponsive.
Running my server on unraid and having server freeze/unresponsive. Only way to fix it is restarting the docker image.