  We prove optimality of the Gagliardo-Nirenberg inequality
  $$
  \|\nabla u\|_{X}\lesssim\|\nabla^2 u\|_Y^{1/2}\|u\|_Z^{1/2},
  $$
  where $Y, Z$ are rearrangement invariant Banach function spaces and
$X=Y^{1/2}Z^{1/2}$ is the Calder\'on--Lozanovskii space. By optimality, we mean
that for a certain pair of spaces on the right-hand side, one cannot reduce the
space on the left-hand, remaining in the class of rearrangement invariant
spaces. The optimality for the Lorentz and Orlicz spaces is given as a
consequence, exceeding previous results. We also discuss pointwise
inequalities, their importance and counterexample prohibiting an improvement.
