I have a VPS with 9GB RAM, 300GB HDD, 3 GB Swap, 7 Cores. The OS is CentOS 5.7 Final.
I have postgres9.0 running on my machine, with proper tuning done (at least by book/wiki of PostgreSQL).
What happens is most of the times when some complex query run (by complex I mean select with maximum 3 Joins), eventhough ~75% of my RAM is unused there is ~99% swapping is happening.
EDIT : the free RAM i am mentioning here is calculated by (free + buffered + cached) The actually free shown by 'free -m' is hardly ~2%. So correct me if I am wrong here in the first place.
Plus it screws up my disk IO which is most of the time reaching ~100% and slows down everything else. (I tend to believe something's wrong with my disk.)
I dont understand the reason of this much of swapping happening. Is it because of context switching?? Most of the time my processors are idle, while the IO wait goes upto 30% during pick times.
Would appreciate if some can shed some light on it.