@Lasse Gismo (Friendica Antifa) not DB related, but I remembered that I had once performance issues when I had a unclean PHP setup with php8.0-fpm and php8.2-fpm (or something like that) running on my raspi and I was all the time optimizing the pool that was not in use for some reason.
How large is you DB in file size? It needs to be managed in RAM next to PHP and the other things running. I am kind of aggressive deleting uninteresting / unclaimed content on my node.