First lets revise the basics.

In terms of performance, small storage devices are faster e.g. registers are faster than ram, RAM is faster than hard disk. And Swap is a dedicated partition to be used as paging alternate to RAM when there is not much RAM available.

Now how linux decides when to use swap or not? There is a sysctl parameter called vm.swappiness that is used by linux to decide. vm.swappiness is the kernel parameter that controls how kernel favors swap over RAM. By default its value is 60. So as you guess as value of 0 in the parameter would tell linux More >