High Load on the CPU when doing a search in all libraries

Hello all,

I don’t now if this is issue is related to plexamp or to the plex server itself (I’d say it is related to plexamp and I will explain why later).

The issue: when I do a search (for a track or whatever) in plexamp while having “Search All Libraries” ticked in Experience menu, the CPU load goes crazy high to 100% and stays there for minutes.

First I thought maybe my machine is not powerful enough, but then I migrated my server to an intel i7 12th CPU with 16Gb of RAM, and I still observe the exact same behavior.

I am not sure what the issue is, but I am sure an i7 12th gen should be able to handle a database with hundreds of millions of entries (not saying I have these, I am just saying that given the amount of tracks I have, this should not be an issue for such a machine).

And I think the issue is on plexamp side because I don’t have this kind of issue on the desktop player).

Thank you in advance.

PS: this issue was going on for sometime, but didn’t really bother me that much, but now that I have sorted my tracks in different libraries by genre, it is becoming really painful to search for a track.

I think that was an ill-advised move.
Genres typically have not sharp boundaries. You will face many situations where you are unsure where to sort a certain track. Sometimes even tracks from the same artist and album!

There are many use cases where it makes much more sense to have all music together in one library.
In my opinion, Plexamp’s Radios and Guest DJs work the better the more material they have available.
(Unless you are a connaisseur of such an exotic branch of music, which is utterly incompatible with all other music and will practically never appear in the same play queue with it.)

The high cpu load can at least partly be explained by the fact that plexamp is searching differently. It will try its best to find not only Album artists which match the search term, but also Track artists (which all the other apps don’t even find).
Even so, it can’t hurt to perform the database repair/optimization provided by this: GitHub - ChuckPa/PlexDBRepair: Database repair utility for Plex Media Server databases

Thank you for your advice.

I have specific use cases and the way I sorted the library is ok for my needs.

I did a database repair and it does not really help.

At some point I don’t get why plex has so many issues with the database, I have had a look on how it is built, and based of the amount of data, any querry should absolutely not last more than few milliseconds. And should not necessitate such a big cpu load.

This is nothing personal, but at some point developers should stop blaming user or the database corruption and start thinking about what is causing all these issues to start with (either what is causing the database corruption, or what is inducing such bad queries or data access.)

I am not really waiting for a solution, I have been scrolling through the plex forum for some times, and I know the kind of answers I would get, but I really would like to send a message to the engineer so they can focus on making the database work correctly before adding new features, because with no database the features cannot be used :slight_smile:

1 Like

I actually have an idea to speed up the “all libraries” search if you have other types of libraries (e.g. movies, tv shows); if you just have a bunch of music libraries then yes, it’s going to be slower because of the way the system is designed, and the intent is not for genre-split libraries generally.

I had the same issue even when I had only 4 or 5 libraries as mentioned, but it only started bothering me now that I need to use the general search more often.

Also I don’t get the problem with having one or more libraries. I for sure don’t know how it is built, and don’t pretend having a magical solution, but for me searching in all the library would just result in a loop on all the libraries, which should not result in 4 minutes of 100% CPU load with no output at the end. (I am not trying to be mean in any way, just trying to understand, so I could maybe reorganize my media in a different way)
I even tried some db queries joining media_parts, media_items and 3 times metadata_items to get all the infos for one artist (albums, tracks, file paths etc..) and it only took 23ms and this on all the libraries (even the non audio ones)
I am sure there is other stuff that should be fetched during a search for an artist on plexamp; but going from 23ms to no result/100%CPU/and no result, there is a huge gab.

I also have a libraries for tv shows and movies, but I don’t get how this helps since plexamp is not really supposed to deal with these libraries anymore.

Could you please develop your idea?

It’ll be in the next release; bear in mind it’s not a panacea, if you literally have dozens of music libraries it’s still likely to be pretty slow. The system was not designed for this.

On the other hand when I had everything in one library, I had other kind of issues related to the size of the one library. Thus my choice of dividing it into multiple ones.

How many total tracks/albums? You could also be pushing the limits do the system; having performance issues, then splitting it up and expecting the performance to be better while searching across the entire library doesn’t make a lot of sense to me.

I understand that splitting the libraries will not make it run faster, and it is indeed because of the system limitations that I decided to split the library so it is already pre-segragated without having to count on any computation.

But what I don’t get is the difference there is between the plexamp way of finding ABBA and the way the browser UI gets me ABBA, at the end they both return the artist and its albums, so sorry but I don’t get why one would work and the other won’t (feel free to follow the ABBA link, you will find another funny story about plex :rofl:)

Update: looks like the issue is more related to the way the searched string is handled, from what I observe, each word I write is searched on its own, the longer the string the harder it gets to get an answer without crashing the server.

I have done the test with the song Fly me to the moon:

  • if I search for “fly me to the moon” the CPU reaches 100% and stays there for few minutes and I get no answer
  • if I search for “fly moon” I get the results relatively fast and the CPU only reach 100% for few seconds (which is kind of ok I guess)
  • I tried to add quotes to my search string, but with no success

I also see the same behavior on browser UI.

So I would say it is not only related to plexamp, even though it could be that it is worse on plexamp since it crashes the server.

PS: I did not answer the question How many total tracks/albums? because I can’t hear the excuse of “I it is not design for this”. I mean Plex is a media SERVER, even if I had hundreds of millions of entries, from the moment I have the right hardware to handle it, there should be no issues from database point of view :slight_smile: I really don’t get what could cause this amount of CPU usage especially that everything should have already been pre-parsed and pre-analysed

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.