i keep getting this on my plex decker logs and plex becomes unreachable only a reboot of the container fixes the issue. is plex aware of this and working on a fix. if yes what is the eta? there post about this all over your forums and years old?
A 200ms wait while adding a lot of media, especially when the database hasnât been optimized, is fairly common. There are several tasks hitting the database at one compounded by it being fragmented.
Scheduled Tasks does optimize the database but at some point, the server should also be restarted for those optimizations to become effective (SQLite merges all those optimizations into the main DB)
There is no âFixingâ a slow database. Itâs either optimized properly or itâs not.
If you have a slower CPU â that doesnât help
If you have slow disk I/O â that really doesnât help.
What I can offer you is a tool which I wrote , that provides a huge speed improvement to the DB because it reorganizes the DBs while PMS is stopped
(The key to optimizing a database is that it canât be open & active)
Give it a read.
Understand how to use it.
Try it.
Itâs solved just about everyoneâs problems to date.
so these settings dont do anything ? why doesnt plex do something about this or move to a more suitable database?

I donât know anything about the hardware you have .
How much media (approximate item count) do you have indexed ?
Whatâs the system hardware?
Many of us have i7 / i9 / newer Xeon CPUs with NVMe storage for the PMS metadata because of the amount of media we have.
It was necessary to size the hardware to match the amount of media indexed.
ryzen 5, 64gb of ram, 1tb nvmeâŠhw is not the issue in this case.
How much media do you have indexed?
Did you use my optimization (which is a full export/reload while PMS is shut down) ?
Hardware (per thread speed), because DB access is single-threaded is still likely the issue.
i havenât used your tool yet and i have a lot of media which am not comfortable sharing here but i also think it is beside the point, donât you think.
Iâm not asking for a list.
Iâm asking âHow many itemsâ
( Approximate total of Movies, Episodes, Tracks, and Photos) .
Thatâs all I ask because each indexed item has direct impact on the DB
The easy way â Provide a âls -lahâ of the âDatabasesâ directory
all in total around 50 to 100k including movies and tv shows
Thanks. Thatâs what I needed to know.
I have a good idea why you see the delays you are. (Iâve seen this many times before)
Internal to SQLite (how it stores records) are links / pointers.
After a lot of Insert/update/delete , those chains get long. Can be as much as 10x the amount of media you actually have.
When PMS makes a query, it has to walk ALL those chains.
That takes time.
The tool I have does what PMS canât (operate on an open database)
I suggest:
-
Stop PMS
-
Make a backup copy of the Databases directory (be safe)
-
As root, run my tool.
-
You want options 1, 4, and 3
-
- Check
-
- Repair (the export / import which fixes all tables
-
- Reindex (regenerates table indexes â youâll find âsearchâ is screaming fast again)
PS: I have a newer version of this about to be released. Itâs a lot easier to use
i will do that and just to make sure we are on the same page your tool has nothing to do with this right ? https://support.plex.tv/articles/repair-a-corrupted-database/
If you look at what that page tells you to do, they have some of the steps.
They donât really tell you WHAT to do.
I do more / the rest of what is needed.
I also have the whole thing automated so you donât have to worry about screwing it up
ok i will follow your steps, run your tool and report back. do i need to run this tools once in a while ?
In the next version of the tool, youâll be able to run it weekly or monthly (your choice) via cron.
To share what it looks like to use:
# sudo ./DBRepair.sh stop auto start exit
- Stops PMS
- Auto â runs Check, Repair, Reindex in one step as needed
- Starts PMS
- Exits
can u automate the tool using sytemd instead of cron?
Sure. ExecStart is fine.
Donât forget to give it a shell to launch from
Itâs only dependencies are:
- PMS is installed
- It runs as ârootâ
- It recognizes the PMS environment itâs running on (
so u work for plex. is there a chanche of your tool getting built/ implemented into plex or better yet a different db altogether?
this is a little beyond me but i will follow your github for the next version
Plex selected SQLite because of the other dependent packages theyâd need if they picked something else.
SQLite is plenty for âJoe Typicalâ user.
I have a test database with 340,000 TV episodes in it and I donât get any of the 'Sleeping" errors youâre getting.
I really do think your DB is fragmented to all hell.
Youâre having trouble following running my script ?