# Suggested SQLite3 DB Optimizations

**URL:** <https://forums.plex.tv/t/suggested-sqlite3-db-optimizations/794749>\
**Category:** Plex Media Server\
**Tags:** server-linux\
**Created:** [May 29, 2022, 3:20am UTC](https://forums.plex.tv/t/suggested-sqlite3-db-optimizations/794749 "2022-05-29T03:20:42Z")\
**Posts on this page:** 1\
**Showing post:** 69

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [October 11, 2022, 4:38pm UTC](https://forums.plex.tv/t/suggested-sqlite3-db-optimizations/794749/69 "2022-10-11T16:38:05Z")

</div>

Here is my tool.

1. Stop PMS
2. Run as root
3. If you want the most expedient, I recommend actions:

- Check
- Repair
- Reindex

1. If you want to examine the individual facets,

- Check  
– `ls -la` the database sizes before starting
- Vacuum  
– Now `ls -la` of the databases again
- Reindex  
– One last check

Feel free to check the DB sizes between each step.

The only conflict possible is if PMS is running and you attempt to use the tool AFTER PMS starts.

This tool only checks for PMS at first startup so be careful.

[DBRepair.tar](https://forums.plex.tv/uploads/short-url/kmxxkBt6r62woKQCm7hEhPUSPK4.tar) (40 KB)

I typically see problems with PMS when:

1. There is small, but non-fatal, database damage
2. The WAL & SHM files do not fold back into the main DB at PMS exit (which it ALWAYS should)

NOTE:

I’ve added an extra couple checks based on feedback received.  
Please let me know if you get errors before getting to the main menu.

15-Oct-2022

Restructured Docker test.

---

_[View the full topic](https://forums.plex.tv/t/suggested-sqlite3-db-optimizations/794749)._
