Characterization of schemes whose dualizing complex is perfect I'm wondering if there is a characterization of schemes over a a field $k$ whose dualizing complex is a perfect complex in terms of singularities. E.g. on a proper Cohen-Macauley scheme over a field, the dualizing complex is a sheaf, when is this sheaf have a finite locally free resolution? (Or this never happens unless the scheme is Gorenstein?)
Recall a complex is called a perfect complex if it is locally quasi-isomorphic to a bounded complex of locally free sheaves.  
 A: As Hailong said in his comment this only happens in the Gorenstein case; here is a sketch of an argument.
Suppose $X$ is a quasi-compact quasi-separated scheme with a dualising complex $D$ and let us assume $D$ is perfect. Recall that $\mathsf{D}^\mathrm{perf}(X)$, the category of perfect complexes over $X$, is a rigid tensor category i.e., it is closed symmetric monoidal and  setting, for E a perfect complex, $E^\vee = hom(E,\mathcal{O}_X)$ we have natural isomorphisms
$$ E^\vee \otimes F \cong hom(E,F)$$
for all perfect complexes F (here I am being notationally lazy - of course the internal hom and tensor are the derived ones).
Now we just notice that there are isomorphisms
$$R \cong hom(D,D) \cong D^\vee \otimes D$$
so $D$ is an invertible object with respect to the tensor product in $\mathsf{D}^\mathrm{perf}(X)$. This implies $D$ is isomorphic to a shift of a line bundle on each connected component of $X$ (see for instance Prop 6.4 of "Gluing techniques in triangular geometry" by Balmer and Favi for a short proof, although, I should mention, the result is pretty well known and older than that paper). Thus $X$ is Gorenstein.
