ISIF=2 is correct. It makes no sense to fix some atoms (in your slab) and then optimize all possible structural parameters (i.e. ISIF=3), including positions, cell shape and cell volume.
I want to optimise the in-plane lattice parameter while keeping the inter-plane distances fixed (i.e. selective dynamics with T T F for all the atoms).Should I use ISIF=2 or ISIF=3? Since, ISIF=2 will change only the atom coordinates, whereas I want to relax the cell volume and shape also.
Since your calculation is for a slab with a large vacuum space, if you use ISIF=3, due to the cell shape optimization you most likely will end up with a wrong lattice parameter along the vacuum direction. To avoid this problem, you can perform optimization calculations using ISIF=2 for a series of structures with different in-plane lattice constants (a and b) and fixed out-of-plane lattice constant (c; assuming this is your vacuum direction). You can then draw the resulting Energy versus volume (or lattice constant) dependence and from that obtain the optimal lattice constants and atomic positions. Of course, in this process you can apply your desired selective dynamics constraint tags (like T T F for all atoms), as well.
Thank you Mohammad Saeed Bahramy for the explanation.
Mistakenly, I had used ISIF=3 with top and bottom 2 layers fixed and middle layers as F F T. It changed the entire supercell dimensions. In fact, the ISIF=3 tag changed the alpha, beta, gamma angles from 90 degrees to totally different values.
As you rightly explained, ISIF=2 is the correct option.