Using multiple tracers of large-scale structure allows to evade the limitations imposed by sampling variance for some parameters of interest in cosmology. We demonstrate the optimal way of carrying out a multitracer analysis in a galaxy redshift survey by considering the principal components of the shot noise matrix from two-point clustering statistics. We show how to construct two tracers that maximize the benefits of sampling variance and shot noise cancellation using optimal weights. On the basis of high-resolution N-body simulations of dark matter halos we apply this technique to the analysis of redshift-space distortions and demonstrate how constraints on the growth rate of structure formation can be substantially improved. The primary limitations are nonlinear effects, which cause significant biases in the method already at scales of k<0.1hMpc-1, suggesting the need to develop nonlinear models of redshift-space distortions in order to extract the maximum information from future redshift surveys. Nonetheless we find gains of a factor of a few in constraints on the growth rate achievable when merely the linear regime of a galaxy survey like EUCLID is considered.