2. The function $y=\frac{1}{x^{2}+a x+b}$ (where $a, b$ are non-zero constants) achieves its maximum value under the condition ( ).
(A) $a^{2}-4 b \geqslant 0$
(B) $a^{2}-4 b \neq 0$
(C) $a^{2}-4 b<0$
(D) It depends on the values of $a, b$, cannot be determined
2.C.

Notice that
$$
y=\frac{1}{x^{2}+a x+b}=\frac{4}{4\left(x+\frac{a}{2}\right)^{2}+4 b-a^{2}} \text {. }
$$
(1) If $a^{2}-4 b \geqslant 0$, then $x^{2}+a x+b=0$ has real roots, in which case, $y$ has no maximum value;
(2) If $a^{2}-4 b<0$, then $0<y \leqslant \frac{4}{4 b-a^{2}}$.
In summary, when $a^{2}-4 b<0$, $y_{\text {max }}=\frac{4}{4 b-a^{2}}$.