Jump to content

Increase cache size of DB for better load times?


jl94x4

Recommended Posts

So im a former Plex user and the biggest feature i miss is storing the DB in RAM for much faater responce times.

This was achieved by using this command.

 

sqlite3 -header -line "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" "PRAGMA default_cache_size = 1000000"

Is there a way to do this on Emby?

Edited by jl94x4
  • Like 1
Link to comment
Share on other sites

FYI this is a sqlite param that allows for a larger cache size. That's not the same thing as putting the db in memory.

  • Like 1
Link to comment
Share on other sites

FYI this is a sqlite param that allows for a larger cache size. That's not the same thing as putting the db in memory.

 

Maybe so, it does considerately improve loading times. Does anything like this exist for Emby?

Link to comment
Share on other sites

  • 2 months later...
ddurdle

One of my test servers has very large test database of media.  The larger it got, the more cpu-bound wait i/o I've been witnessing.  Doing a trace, most of the i/o waits was caused for the constant reading of library.db.  I found the file fragmented over the disk (which is understandable).  At very minimum, making a copy and replacing the original with the copy will eliminate this fragmentation.  Even better performance could be had by moving your .db files to faster disk.  My test servers are all running on the cheaper side.  I don't want to be "that guy" that specs out a test server to be $65/month just to have enough cpu, SSD, etc.

 

A "free" way of gaining a lot of performance would be to move the db file to RAM.  Just like your original question about moving the library to RAM.  My library db is only about 800MB, so I created a "ramdisk" and relocated the file to there.  The performance gains is night and day.  It was taking sometimes nearly a minute to navigate around the huge library.  Now it is instantaneous.  The system has that "fresh" feel and has the responsiveness of a system with a library of just 100 video files.

 

Extreme care must be done if you decide to try this.   Init scripts to create the file on the ramdisk on startup, link the file to the ramdisk, backup the file on shutdown.  Schedule online dirty backups of the file as well.  There are lots of tricks to this.

Link to comment
Share on other sites

Jambercob

If you have enough memory you could just use the portable version of emby server and run it from a ramdisk (I'm currently doing this). The load times are nearly instant and that's with an extremely large library.

 

Of course as mentioned above, you would need to make sure the ramdisk syncs to a folder or image file and is loaded again upon startup. I set mine to just sync changes once a day and then the folder it syncs to is also backed up to another disk. I do not sync on system reboots because it would take 20+ minutes to do a reboot.

Link to comment
Share on other sites

Riggs

FYI this is a sqlite param that allows for a larger cache size. That's not the same thing as putting the db in memory.

 

Ok, for me this is better. However, is there some trick to optimize/refresh the database?

 

Thanks in advance

Link to comment
Share on other sites

In the future we can look at the ability to offer the vacuum command.

  • Like 2
Link to comment
Share on other sites

Riggs

In the future we can look at the ability to offer the vacuum command.

 

 

Awesome, thank you!

Link to comment
Share on other sites

Riggs

Compacting the Database appears to help speed things up a bit.

 

@@PenkethBoy has a PowerShell script for Windows users.

 

I have to say thank you, the system not allow me say thanks in your comment

 

Done!

 

I do the process, looks better  :)

Edited by HRSCR
Link to comment
Share on other sites

maximumentropy

My system's performance is terrible, almost completely unusable, without something like this.  I've been using a kludge for some time now to mitigate the problem ... I wrote a simple a python script to read library.db every 5 seconds.  This forces it to stay in the windows in-RAM cache.  With that running all the time, the performance is great.

 

For what it's worth, I do a manual VACUUM / ANALYZE / REINDEX every once in a while, but it's not enough by itself to maintain normal performance here.

 

It would be great if Emby server did something internally to keep the database in cache.

 

Thanks!

  • Like 1
Link to comment
Share on other sites

ddurdle

If you have enough memory you could just use the portable version of emby server and run it from a ramdisk (I'm currently doing this). The load times are nearly instant and that's with an extremely large library.

 

Of course as mentioned above, you would need to make sure the ramdisk syncs to a folder or image file and is loaded again upon startup. I set mine to just sync changes once a day and then the folder it syncs to is also backed up to another disk. I do not sync on system reboots because it would take 20+ minutes to do a reboot.

 

You don't need to store and run Emby from RAM.  You want to store the database files on ramdisk.  In windows you can use junction points to link the db files from emby to the ramdisk db files or use symlinks on Mac/Linux/other.

 

You could also store the cache files on ramdisk the db files themselves is the bottleneck.

  • Like 1
Link to comment
Share on other sites

Jambercob

Good point @@ddurdle. If you're looking to just do the db file you sure could use a symbolic link within whichever OS you're running.

Link to comment
Share on other sites

  • 5 months later...

You don't need to store and run Emby from RAM.  You want to store the database files on ramdisk.  In windows you can use junction points to link the db files from emby to the ramdisk db files or use symlinks on Mac/Linux/other.

 

You could also store the cache files on ramdisk the db files themselves is the bottleneck.

 

Would I still need to a) copy the file to Ramdisk each time, B) arrange for the ramdisk to save the file to 'real' storage at regular intervals? I am thinking of using the AMD Ramdisk sw.

Link to comment
Share on other sites

I am trying to see if this will improve the 4-5 minute wait for Collections to appear on my HTPC. I have >1500 movies, and 4 collections. 1 collection has 37 movies, the other 3 just 10 or less each.

Link to comment
Share on other sites

Happy2Play

I am trying to see if this will improve the 4-5 minute wait for Collections to appear on my HTPC. I have >1500 movies, and 4 collections. 1 collection has 37 movies, the other 3 just 10 or less each.

 

The change to the next release (3.6) should improve those times

Link to comment
Share on other sites

  • 4 weeks later...

Seems better timing now on 3.5.3. Not consistent though.

 

I think I will see if cleaning up the db helps even more, it is now >650mb

Link to comment
Share on other sites

  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...