# SLOW QUERY errors

**URL:** <https://forums.plex.tv/t/slow-query-errors/725292>\
**Category:** Plex Media Server\
**Tags:** server-docker, server-unraid\
**Created:** [June 28, 2021, 1:40pm UTC](https://forums.plex.tv/t/slow-query-errors/725292 "2021-06-28T13:40:46Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Sky952](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@Sky952](https://forums.plex.tv/u/Sky952)\
**Post date:** [August 31, 2021, 12:00am UTC](https://forums.plex.tv/t/slow-query-errors/725292/42 "2021-08-31T00:00:04Z")

</div>

I’ve came across this issue it seems that when you have large collection of movies/ tv shows the sqlite database can’t handle the amount of transactions with default cache size.  
I was able to fix it by increasing the “PRAGMA default\_cache\_size” on the plex db.

depending on your setup, if you’re on linux:  
install sqlite3: “sudo apt install sqlite3”  
stop the plex media server  
locate the plex DB directory, depending on installation it should be in “/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases”

once you’ve cd to that directory run the following:  
sqlite3 com.plexapp.plugins.library.db  
PRAGMA default\_cache\_size = 600000000; (this number is in bytes) so my value is 600MB  
PRAGMA default\_cache\_size; (this will repeat the value entered as a confirmation  
.exit (this will exit the sqlite session)

Start your plex server back up and you should find it more responsive.

---

<div class="post-metadata">

**Author:** ![triks\_melb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/triks_melb/32/107894_2.png) [@triks\_melb](https://forums.plex.tv/u/triks_melb)\
**Post date:** [August 31, 2021, 12:15am UTC](https://forums.plex.tv/t/slow-query-errors/725292/43 "2021-08-31T00:15:47Z")

</div>

It’s a very large Music only library on a Synology NAS (Linux) so I’ll give that a go…

---

<div class="post-metadata">

**Author:** ![Sky952](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@Sky952](https://forums.plex.tv/u/Sky952)\
**Post date:** [August 31, 2021, 12:39am UTC](https://forums.plex.tv/t/slow-query-errors/725292/44 "2021-08-31T00:39:39Z")

</div>

oh also one more thing might help is in increase your folder watch size

[Linux Tips](https://forums.plex.tv/t/linux-tips/276247/9)

This might help out as well, since the collection is music

---

<div class="post-metadata">

**Author:** ![triks\_melb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/triks_melb/32/107894_2.png) [@triks\_melb](https://forums.plex.tv/u/triks_melb)\
**Post date:** [August 31, 2021, 1:05am UTC](https://forums.plex.tv/t/slow-query-errors/725292/45 "2021-08-31T01:05:45Z")

</div>

Is the cache size dependant on RAM (my NAS is 4GB) or how do I determine the right cache size?

PMS on the Synology DSM 7 is located at

“/var/packages/PlexMediaServer/home/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db”

sqlite3 is at usr/bin

---

<div class="post-metadata">

**Author:** ![Sky952](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@Sky952](https://forums.plex.tv/u/Sky952)\
**Post date:** [August 31, 2021, 1:29am UTC](https://forums.plex.tv/t/slow-query-errors/725292/46 "2021-08-31T01:29:28Z")

</div>

Yeah the cache size is depending on how much ram you have 🙂 I have 16GB in my server and I only gave mine 600 MB it made a huge difference.

---

<div class="post-metadata">

**Author:** ![Volts](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@Volts](https://forums.plex.tv/u/Volts)\
**Post date:** [August 31, 2021, 3:37am UTC](https://forums.plex.tv/t/slow-query-errors/725292/47 "2021-08-31T03:37:27Z")

</div>

Do you believe Plex uses `default_cache_size`? I don’t think it does, and I don’t believe setting `default_cache_size` in the .db file is effective.

I’ve observed that Plex Media Server explicitly sets `cache_size` when opening database files, overriding and ignoring any `default_cache_size` set in the .db file. I’ve had luck modifying the `cache_size` value(s) directly in the Plex Media Server binary.

The unit for `cache_size` actually isn’t bytes, it’s pages. The default size of a SQLite page is 4K. I’ve also had success rebuilding the databases to use a larger 16K page, which indirectly allows still more data to be cached.

---

<div class="post-metadata">

**Author:** ![Sky952](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@Sky952](https://forums.plex.tv/u/Sky952)\
**Post date:** [August 31, 2021, 3:43am UTC](https://forums.plex.tv/t/slow-query-errors/725292/48 "2021-08-31T03:43:31Z")

</div>

you mind showing me a screenshot or a stacktrace of this explicitly being set by Plex? because when I check the schemas it’s set to the value that I applied?

---

<div class="post-metadata">

**Author:** ![Volts](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@Volts](https://forums.plex.tv/u/Volts)\
**Post date:** [August 31, 2021, 3:48am UTC](https://forums.plex.tv/t/slow-query-errors/725292/49 "2021-08-31T03:48:34Z")

</div>

`PRAGMA default_cache_size` is deprecated by SQLite, so it’s expected that `PRAGMA cache_size` is configured by each connecting app.

I created a trigger to log the active value of `SELECT pragma_cache_size` when Plex performs database operations. It’s **2000** for primary database activity, and **cache\_size=2000** appears in the Plex Media Server binary.

---

<div class="post-metadata">

**Author:** ![triks\_melb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/triks_melb/32/107894_2.png) [@triks\_melb](https://forums.plex.tv/u/triks_melb)\
**Post date:** [August 31, 2021, 4:12am UTC](https://forums.plex.tv/t/slow-query-errors/725292/50 "2021-08-31T04:12:30Z")

</div>

Applying the change with 600MB setting hasn’t changed the amount of RAM PMS is utilising - does that indicate the changes are not effective?

---

<div class="post-metadata">

**Author:** ![Atomatth](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/atomatth/32/314355_2.png) [@Atomatth](https://forums.plex.tv/u/Atomatth)\
**Post date:** [August 31, 2021, 1:14pm UTC](https://forums.plex.tv/t/slow-query-errors/725292/51 "2021-08-31T13:14:17Z")

</div>

@SpuddyUK You’re the OP so I want to circle back to you. If I’m not mistaken you’re not observing any issue per se and the post was created more or less to determine the cause of these log entries, correct? Please see my [post here.](https://forums.plex.tv/t/slow-query-errors/725292/34) For the most part these messages can be ignored unless you are noticing extreme times or observing an issue while using Plex.

Everyone else,

This thread is becoming a dumping site for multiple issues unrelated to the OP, which was a general question [see above]. Yes, these messages exist in your logs. That is not an issue.

Please create separate threads with the exact issue that you’re observing. @dom_a2345 Sonic Analysis running without any music library, thats an issue. @telfordje & @triks_melb have issues related to scanning music libraries, thats a separate issue. @jakehoms you already have your own thread, we can continue there.

I’m not trying to dismiss anyone’s issues, simply trying to keep these issues organized to get the correct team members looking at the issue if needed. Please `@me` when you create your new threads if you like.

---

<div class="post-metadata">

**Author:** ![SpuddyUK](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@SpuddyUK](https://forums.plex.tv/u/SpuddyUK)\
**Post date:** [August 31, 2021, 1:48pm UTC](https://forums.plex.tv/t/slow-query-errors/725292/52 "2021-08-31T13:48:47Z")

</div>

@Atomatth Yes, correct. No issues so to speak (that I can tell), but looking for the cause/resolve of the log entries. I think there are a few murmurs that SQLite is probably not the optimal DB for plex, especially those with large DB’s/Libraries. Are there any plans to allow migration to another DB engine?

I do agree the post has been somewhat side-tracked by additions that don’t seem to match the original post.

---

<div class="post-metadata">

**Author:** ![ilia1985](https://avatars.discourse-cdn.com/v4/letter/i/4da419/32.png) [@ilia1985](https://forums.plex.tv/u/ilia1985)\
**Post date:** [August 31, 2021, 4:23pm UTC](https://forums.plex.tv/t/slow-query-errors/725292/53 "2021-08-31T16:23:53Z")

</div>

Hi, I’m have the same issue for 2 weeks now and tried everything including using different pms versions. Those errors actually do cause a problem which very noticable when exiting a playback then going back to library results in high CPU spike to 70%+. Here I watched logs. [Plex Media Server Logs\_2021-08-31\_13-15-41.zip](https://forums.plex.tv/uploads/short-url/lDwIIpY1ofG73uoKvusOow56KZE.zip) (2.2 MB)

---

<div class="post-metadata">

**Author:** ![Volts](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@Volts](https://forums.plex.tv/u/Volts)\
**Post date:** [August 31, 2021, 5:37pm UTC](https://forums.plex.tv/t/slow-query-errors/725292/54 "2021-08-31T17:37:00Z")

</div>

I think your system may have additional issues beyond SLOW QUERY messages.

You might want to start a new thread and give some additional information about your system and configuration.

I believe that this is a sign your database may need to be [repaired](https://support.plex.tv/articles/repair-a-corrupted-database/) or restored from a backup:

```auto
Plex Media Server.2.log:Aug 31, 2021 11:28:46.559 [5920] ERROR - SQLITE3:0xd29110a2, 11, database corruption at line 79051 of [bf8c1b2b7a]
...
Plex Media Server.2.log:Aug 31, 2021 11:28:46.562 [5920] ERROR - Soci Exception handled: sqlite3_statement_backend::loadRS: database disk image is malformed

```

I also wonder if you have aggressive antivirus/network security software running, or perhaps a VPN on the same server? That may be a red herring; address the DB corruption issue first.

* * *

@atomatth - It would be nifty if Plex could alert in the Web app about database integrity:

```auto
Plex Media Server.4.log:Aug 31, 2021 09:08:52.840 [3848] ERROR - [Database backup/com.plexapp.plugins.library.db] The database failed its integrity check, not backing up.

```

---

<div class="post-metadata">

**Author:** ![triks\_melb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/triks_melb/32/107894_2.png) [@triks\_melb](https://forums.plex.tv/u/triks_melb)\
**Post date:** [August 31, 2021, 11:15pm UTC](https://forums.plex.tv/t/slow-query-errors/725292/55 "2021-08-31T23:15:31Z")

</div>

Couldn’t agree with you more about ditching SQLite @SpuddyUK but perhaps there is a reason for why they chose it in the first place.

---

<div class="post-metadata">

**Author:** ![ilia1985](https://avatars.discourse-cdn.com/v4/letter/i/4da419/32.png) [@ilia1985](https://forums.plex.tv/u/ilia1985)\
**Post date:** [September 1, 2021, 2:37am UTC](https://forums.plex.tv/t/slow-query-errors/725292/56 "2021-09-01T02:37:29Z")

</div>

Thanks I missed that 1 in the log. As for my system I’m running pms on a xeon 5218 64gn ram and win server 12 R2. And no aggressive network security. Of you don’t mind can guide me how to repair data base? Thanks

---

<div class="post-metadata">

**Author:** ![Volts](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@Volts](https://forums.plex.tv/u/Volts)\
**Post date:** [September 1, 2021, 7:00am UTC](https://forums.plex.tv/t/slow-query-errors/725292/57 "2021-09-01T07:00:33Z")

</div>

This Plex support doc is pretty good!

> **[Repair a Corrupted Database | Plex Support](https://support.plex.tv/articles/repair-a-corrupted-database/)**
>
> Note: This article is for Plex Media Server version 1.23.2 and newer. If using an earlier version, see . Though...

---

<div class="post-metadata">

**Author:** ![Tomspools](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Tomspools](https://forums.plex.tv/u/Tomspools)\
**Post date:** [September 3, 2021, 1:46am UTC](https://forums.plex.tv/t/slow-query-errors/725292/58 "2021-09-03T01:46:41Z")

</div>

your comment on rebuilding the db to use a 16k page caught my eye as my db is huge and dying a painful death. do you have a how to or a link?

---

<div class="post-metadata">

**Author:** ![triks\_melb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/triks_melb/32/107894_2.png) [@triks\_melb](https://forums.plex.tv/u/triks_melb)\
**Post date:** [September 3, 2021, 2:25am UTC](https://forums.plex.tv/t/slow-query-errors/725292/59 "2021-09-03T02:25:29Z")

</div>

I’d be curious to see if the large DB not coping well is a hardware limitation or Plex/SQLite issue.

With around 500k of tracks I’m at the stage where I’m going to move away from PlexAmp/Plex for main music library and try Synology’s Audio Station and see if that runs better - which I suspect it might. Can’t handle seeing these messages!

 ![plex-something went wrong](https://global.discourse-cdn.com/plex/original/3X/9/3/93a27632e0a2238205659069f74e2722c0780714.jpeg)

---

<div class="post-metadata">

**Author:** ![Atomatth](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/atomatth/32/314355_2.png) [@Atomatth](https://forums.plex.tv/u/Atomatth)\
**Post date:** [September 3, 2021, 1:38pm UTC](https://forums.plex.tv/t/slow-query-errors/725292/60 "2021-09-03T13:38:46Z")

</div>

@triks_melb From your last logs, you have some audio files that are causing issues with the scanner. Check your `Plex Media Scanner Matcher.log` files for the culprits. Also, please create a separate thread for your issue.

---

<div class="post-metadata">

**Author:** ![triks\_melb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/triks_melb/32/107894_2.png) [@triks\_melb](https://forums.plex.tv/u/triks_melb)\
**Post date:** [September 4, 2021, 1:38am UTC](https://forums.plex.tv/t/slow-query-errors/725292/61 "2021-09-04T01:38:41Z")

</div>

thanks @Atomatth I’ve removed the 3 offending artists and will force a re-scan.

[Previous page](https://forums.plex.tv/t/slow-query-errors/725292.md?page=2)

[Next page](https://forums.plex.tv/t/slow-query-errors/725292.md?page=4)
