I've set swappiness on my DB server to zero, but during a large sort operation the swap space used grew even as the cache was still using a lot of memory, and then cache grew but swap was left alone. This makes no sense to me. Here's free -m
as of now:
total used free shared buffers cached
Mem: 16000 15979 20 0 24 10520
-/+ buffers/cache: 5434 10565
Swap: 6111 5478 633
This is happening in the middle of a large sort in PostgreSQL. The issue is that the swapped out memory will probably be called upon as soon as the sort is over (it's a big UPDATE
on a table I put into tmpfs), resulting in a huge slowdown as it will be random access.