I am running a ODroid HC4 as a media server with Jellyfin and Navidrome.

After expanding my music collection to about 70k tracks, Navidrome’s search performance was terrible. Searching for tracks took more than 10 seconds.

I know that Navidrome’s search just uses SQLite LIKE statements without an index, so the performance is not optimal, but it could definitely be better. However, the main reason for the bad performance was the slow microSD storage.

My ODroid may have slow storage, but it has plenty of RAM (4GB). So it should be possible to keep a 160MB database permanently cached. Turns out, there is an application that can permanently keep certain files in RAM: vmtouch.

You can install it with apt and then run the command vmtouch -vtl database.sqlite. This will keep the file locked in RAM as long as the program is running.

VMTouch also comes with a service to permanently keep certain files cached. To set it up, you have to edit the config file under /etc/default/vmtouch and restart the service.

# Change to yes to enable running vmtouch as a daemon
ENABLE_VMTOUCH=yes

# User and group to run as
VMTOUCH_USER_GROUP=root:root

# Whitespace separated list of files and directories for vmtouch to operate on
VMTOUCH_FILES="/apps/data/navidrome/navidrome.db"

# Options to pass to vmtouch itself. See vmtouch(8).
VMTOUCH_OPTIONS="-tld"

Now the music database is always kept in RAM, which improved the search speed to 300-600ms.

Source: https://www.baeldung.com/linux/file-cache-ram