Is this useful identity valid only under the integral sign? Studying dimensional reugularization one often encounters the following identity:
$$
\int d^d q\, \, q^\mu q^\nu f(q^2) = \frac{1}{d}g^{\mu\nu}\int d^d q\,\,  q^2 f(q^2)
$$
often justified by some symmetry arguments which I admit i never really understood, and since I didn't understand them I tried to prove the identity mathematically, the proof below is valid in general, so I ask you

*

*Is it really valid outside of the integral sign? If it isn't, why?

*Independently of the answer to the first question can someone explain me with clarity and details the reasons why that identity is true, without doing the proof, like basically every textbook does?

My proof basically relies on index gymnastics:
$$
q^\mu q^\nu = g^{\mu\rho} g^{\sigma\nu} q_\rho q_\sigma
$$
multiplying by $g^{\rho\sigma}$ on both sides
$$
g^{\rho\sigma}q^\mu q^\nu = g^{\mu\rho} g^{\sigma\nu} q^2.
$$
Multiplying now by $g_{\rho\sigma}$
$$
g_{\rho\sigma} g^{\rho\sigma}q^\mu q^\nu = g_{\rho\sigma} g^{\mu\rho} g^{\sigma\nu} q^2
$$
which is equal to
$$
d \,\,q^\mu q^\nu = \delta^\mu_\sigma g^{\sigma\nu} q^2 = g^{\mu\nu} q^2
$$
which is equivalent to
$$
q^\mu q^\nu = \frac{1}{d} g^{\mu\nu} q^2
$$
Which is the required identity.
On the other end i don't see why terms like $q^0 q^1$ would be zero in general, if $q$ is momentum for example, $q^0 q^1$ is just the product of energy and momentum along the x direction, why would it be zero?
 A: Your proof is not valid. The $\rho$ and $\sigma$ indices are dummy indices in a summation, attempting to multiply by $g^{\rho\sigma}$ on both sides amounts to multiplying each term in a sum by different factors (which results in an inequivalent expression).
The argument is fundamentally one of symmetry of the integration region, hence why there needs to be an integral. It is basically the same flavor of logic as one uses to simplify the integration of odd/even functions over symmetric intervals in one dimension. If you specialize to the Minkowski metric and integrate over all space (as I suspect will generally be the case for your application), it will be easier to see why the result is valid.
A: 
Proposition. If the integrals
$$\begin{align}
I^{\mu\nu}~:=~&\int_{\mathbb{R}^d}\! \frac{d^dq}{(2\pi)^d} f(q^2) q^{\mu}q^{\nu},\cr
I~:=~&\int_{\mathbb{R}^d}\! \frac{d^dq}{(2\pi)^d} f(q^2) q^2,
\end{align}\tag{1} $$
are convergent, then
$$
I^{\mu\nu}~=~g^{\mu\nu}I/d.\tag{2}$$

Sketched proof of eq. (2): First Wick-rotate to Euclidean signature $$g^{\mu\nu}~=~\delta^{\mu\nu}.\tag{3}$$ Secondly, off-diagonal $I^{\mu\nu}$ must be zero, because the integrand is then odd. Thirdly, the diagonal elements
$$ I^{11}~=~I^{22}~=~\ldots~=~I^{dd} \tag{4}$$
must all be equal. Fourthly, by definition
$$ I~\stackrel{(1)}{=}~I^{11}+I^{22}+\ldots+I^{dd}.\tag{5}$$
Combine the above observations to derive the sought-for eq. (2). $\Box$
It is not hard to see that the sought-for identity does not hold without the integral sign.
References:

*

*M.E. Peskin & D.V. Schroeder, An Intro to QFT; eq. (6.46).

A: Since the integrand is a Lorentz (2,0) tensor so must be the answer. Your integrand does not depend on any other momenta or position vectors or tensors so the only two tensor that (Always) exists in the problem is the metric tensor. Hence the result must be proportional to it. The result is definitely not valid outside of the integral (there is, however a tensor decomposition into antisymmetric, trace and symmetric traceless parts. 
A: This identity is true even outside the integral sign. It is just a consequence of $g^{\mu\nu}g_{\mu\nu}=d$, as you observed in your proof.
