The Optimize Database scheduled task reduces the database size. It runs once/week.
Selecting Optimize Database from Settings → Troubleshooting does not reduce the database size (it did not on my Plex server).
You can use WebTools-NG Butler Scheduled Tasks to start the scheduled task immediately.
WebTools-NG runs on PC/Mac/Linux (download). It does not have to run on the same system as Plex Media Server.
You will need some free space. During the process, the -wal database file grows to the same size as the bloated db.
That’s Docker or UnRAID, not Plex. Hopefully someone familiar with them can assist.