TITLE: Compactifications of varieties with small complement
QUESTION [9 upvotes]: Let $X$ be a smooth variety over an algebraically closed field $k$. If it makes things easier, $X$ may be assumed to be quasi-projective. By Nagata (or quasi-projectivity) there exists a proper variety $\bar{X}$ which contains $X$ as a dense open subvariety, and by the smoothness of $X$ we may assume $\bar{X}$ to be normal. 
Are there any criteria/theorems which give information about the codimensio of the $\overline{X}\setminus X$? 
The same question can be asked if we assume resolution of singularities, such that we may assume $\overline{X}$ to be smooth. Under which conditions can a smooth compactification $\overline{X}$ be found such that $X$ has complement of codimension $>1$ in $\overline{X}$?
Finally, to rephrase, how can one detect whether a given smooth variety $X$ arises by removing a codimemsion $>1$ closed subvariety from some proper variety?

REPLY [6 votes]: I don't think you can hope for any kind of useful conditions, here are just some
comments. 
Even if $X$ is smooth, whether or not we demand the compactification
matters. Let for instance $X'$ be a smooth projective surface containing a $(-2)$-curve $C$,
i.e., $C$ is isomorphic to $\mathbb P^1$ with self-intersection $-2$. Put
$X:=X'u C$. Then there is no smooth compactification of $X$ with
complement of codimension $³2$ but there is a normal one. In fact $C$ can be
contracted to a point on a normal surface but that point is singular with a non-trivial
local fundamental group. This fundamental group is an invariant of $X$ at
infinity and would be trivial if we could add a smooth point instead. 
I think (haven't checked) that there is also for surfaces a distinction between
proper and projective (non-smooth) compactifications. If one does the usual
thing of blowing up $10$ general points on a smooth cubic, then the complement
of the strict transform of the cubic has a proper compactification by adding
just one point but I don't think it has a projective such compactification.
If $X$ has a projective normal compactification $\overline X$ then there are
some necessary conditions such as the space of global functions being finite
dimensional. In fact for a line bundle on $\overline X$, its space of section
are the same on $X$ as on $\overline X$ and hence using an ample line bundle on
$\overline X$ we see that $\overline X$ is the $\mathrm Proj$ of the algebra of
sections of powers of some line bundle on $X$. If we furthermore assume that
$\overline X$ is smooth, then any line bundle on $X$ extends to $\overline X$
and will in particular have a finite dimensional space of sections.
Hence a reasonable question is if the condition that all line bundle have finite
dimensional spaces of sections is enough to get a (smooth?) compactification
with complement of codimension $>1$. I think that for surfaces the answer may be
positive but feel dubious about higher dimensions.