My guess is that it’s as simple as you need more ram. At the very least add more swap.
How big is your database?