1.2 billion records in STATISTICS_MEDIA

Server Version#: plexmediaserver_1.24.4.5081-e362dc1ee_amd64
Player Version#: various

  • DB re-created in June
  • around 3k movies/TV episodes
  • 1 regular user that plays <5 items per week
  • DB is 40GB
  • 1 211 708 001 entries in the STATISTICS_MEDIA table

Half a million records for each media item.

I see I am not the only one with this issue: Database size is 12GB and there are 140 millions rows in statistics_media table - #4 by Victor_Kozak (closed but unresolved from my POV)

Is this a known bug? Do I need to implement some sort of regular maintenance?

Hi.

Plex team will not fix it and will not answer. I just removed statistics table from DB ~ year ago and forgot about this issue (sometimes I can see warnings in log - “statistics table does not exist, bla bla bla …”).

Maybe: Plex Database sqlite file has more than doubled in 10 days

The above linked issue was a side effect of a client in the local network which was not signed into the plex account.
But a fix for this should already be in your server release.

Do you let your server perform its maintenance routine during the night?
If not, do it.

Running a database optimize should fix this if it’s related to the previously mentioned bug.

Settings → Troubleshooting → Optimize Database

Very interesting, I thought I want to try deleting the records that have no account_id (NULL) via command line sqlite that comes with plex. That took forever for just 100 records, so I transferred it onto my desktop machine and used the sqlite browser to do the same. Deleting 1m records takes around 8s.

But then I tried optimize DB as you mentioned and lo and behold, this was speedy (how do you do this???*) and now the DB is… 58MB.

I think it all has to do with my outdated MacOS client - I am one of those HTPC users.

Thank you drzoidberg33!

Edit 1: Update Nov 28th: I just checked again, DB is still small, a single new record on the statistics table.