For every positive regular Borel measure, possibly infinite valued, vanishing
on all sets of p-capacity zero, we characterize the compactness of the
embedding W^{1,p}({\bf R}^N)\cap L^p ({\bf R}^N,\mu)\hr L^q({\bf R}^N) in
terms of the qualitative behavior of some characteristic PDE. This question is
related to the well posedness of a class of geometric inequalities involving
the torsional rigidity and the spectrum of the Dirichlet Laplacian introduced
by Polya and Szeg\"o in 1951. In particular, we prove that finite torsional
rigidity of an arbitrary domain (possibly with infinite measure), implies the
compactness of the resolvent of the Laplacian.Comment: 19 page