The main problem is that \textsf only changes the current family to \sfdefault (which corresponds to whatever the class or loaded packages set, the default out of the box is cmss for Computer Modern Sans), as explained in Difference between \textrm{} and \mathrm{} for \textrm and \mathrm, but the same concepts apply here.
By loading amsmath, all \textXY commands can be used in math mode and they automatically change size according to the current math style (\displaystyle and \textstyle in the current font size, \scriptstyle and \scriptscriptstyle reduced size, depending on the current font size).
On the contrary, \mathsf is usually set up for choosing sans serif upright medium, in the current font size (or reduced in subscripts and superscripts). This is much more efficient in terms of processing time than using \textsf, but in cases when one is short of math groups, a good alternative is to avoid using up one of them just for a little number of cases.
One can do with
\usepackage{amsmath} % for enabling reduced size in sub/superscripts
\let\mathsf\relax % just to avoid a message in the log file
\DeclareRobustCommand{\mathsf}[1]{\text{\normalfont\sffamily#1}}
that ensures the same font selection as made by \mathsf, independently of the context. This redefinition should be made after loading font packages that can issue a \DeclareMathAlphabet{\mathsf} command.
If \mathsf has not been used in advance for typesetting (usage in definitions are not important), a math group will be effectively saved at the expense of processing time (some milliseconds, probably, with fast machines).
\textrm{}and\mathrm{}– Werner Mar 02 '13 at 05:47\mathsfwithout using a math alphabet", it won't be a duplicate any more. – egreg Mar 02 '13 at 10:58