Stalk of structure sheaf on fiber product of schemes

Fiber products exist in the category of locally ringed spaces (see e.g. Gillam's paper), and this also provides a direct construction (without gluing!) of the fiber product of schemes and reveals its explicit structure as a locally ringed space.

If $f : X \to S$ and $g : Y \to S$ are morphisms of locally ringed spaces, then the fiber product $X \times_S Y$ has the following description: Elements are of the form $(x,y,s,\mathfrak{p})$, where $(x,y,s)$ lies in the underlying topological fiber product, i.e. $x \in X$, $y \in Y$ with $f(x)=s=g(y)$, and $\mathfrak{p} \subseteq \mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y}$ is a prime ideal satisfying $\mathfrak{p} \cap \mathcal{O}_{X,x} = \mathfrak{m}_x$ and $\mathfrak{p} \cap \mathcal{O}_{Y,y} = \mathcal{m}_y$. The stalk of the structure sheaf at such a point is the localization $(\mathcal{O}_{X,x} \otimes_{\mathcal{O}_{S,s}} \mathcal{O}_{Y,y})_{\mathfrak{p}}$. As for the topology and the structure sheaf in general, one uses (as in the construction of affine schemes) localization at elements $f \notin \mathfrak{p}$.

Actually, all this can be derived from the universal property of local schemes and the universal property of fiber products (exercise).


No, it is not true that $\mathcal O_{x,X}\otimes_{\mathcal O_{z,Z}} \mathcal O_{y,Y}$ and $\mathcal O_{w,W}$ are isomorphic.
Take for example $X=Y=Spec (\mathbb C)$ and $Z=Spec (\mathbb R)$, with the obvious morphisms.
Then $$W=X\times_Z Y=Spec (\mathbb C)\times_{Spec(\mathbb R)}Spec(\mathbb C)=Spec (\mathbb C\otimes_\mathbb R\mathbb C)=Spec(\mathbb C\times \mathbb C)=\lbrace w_1,w_2\rbrace$$
We have $$\mathcal O_{w_1,W}=\mathcal O_{w_2,W}=\mathbb C\neq \mathcal O_{x,X}\otimes_{\mathcal O_{z,Z}} \mathcal O_{y,Y}=\mathbb C\otimes_\mathbb R\mathbb C=\mathbb C\times \mathbb C$$ Notice that the right hand side isn't even a local ring!
I'm happy that your question allows me to somehow illustrate the point I made in the Edit here


The answer of Georges is crystal clear. Let me present another example with $Z=\mathrm{Spec}(k)$ ($k$ is a field), $X=Y=\mathbb A^1_k$ and $x,y$ rational over $k$.

Write $X=\mathrm{Spec}(k[t]), Y=\mathrm{Spec}(k[s])$ and consider $x=0$ and $y=0$. The spectrum of $R:=O_{X,x}\otimes_k O_{Y,y}$ is a nice and surprising object. It is noetherian, integral, regular (even UDF) of dimension $2$, all closed points are of height 1 (and there are infinitely many such points) except the one corresponding to $(0,0)$ which has height 2. In particular the tensor product is not a local ring. Not even semi-local.

Indeed $O_{X,x}=T^{-1}k[t], O_{Y,y}=S^{-1}k[s]$, where $T$ is the set of polynomials in $k[t]$ not vanishing at $0$. Similarly for $S$. So the tensor product is $R=T^{-1}k[t]\otimes_k S^{-1}k[s]=U^{-1}k[t,s]$ where $U=TS$ consists in the products of elements of $T$ and $S$. This is a localization of $k[t,s]$ so is integral, noetherian, regular and UDF.

The spectrum $\mathrm{Spec}(R)$ corresponds to prime ideals of $k[t,s]$ with empty intersection with $U$. It is easy to see that there is only one maximal ideal of $k[t,s]$, $(t,s)k[t,s]$, in this set (suppose $k$ algebraically closed if you like). The other ones are $0$ and principal irreducible ones $f(t,s)k[t,s]$. Now $f(t,s)k[t,s]\cap U=\emptyset$ if and only if $f(t,s)\notin k[t]\cup k[s]$. The ideal $f(t,s)k[t,s]\subseteq (t,s)$ if and only if $f(0,0)=0$. These $f$ correspond to prime ideals specializing to $(0,0)$. They are non closed points in $\mathrm{Spec}(R)$. The other $f(t,s)$ define prime ideals in $R$ not strictly contained in another prime ideal, so they define closed points. Examples of such $f(t,s)$: take $c+t+sg(s)$ with $c\in k^*$ and $g(s)\in k[s]$.

From this description we see that $\dim R=2$ and the only closed point with height 2 is the ideal $(t,s)R$.

Geometrically (say $k$ algebraically closed), $V:=\mathrm{Spec}(T^{-1}k[t])$ is the complement of $F=$ {points of $\mathbb A^1_k$ which don't specialize to $0$}. So $V\times_k V$ is the complement of $F\times \mathbb A^1\cup\mathbb A^1\times F$. For any irreducible curve $C$ in $\mathbb A^1\times\mathbb A^1$ which is not "vertical" or "horizontal" and not passing through $(0,0)$, the generic point of $C$ belongs to $V\times V$ and is closed in $V\times V$ because all its possible specializations $\mathbb A^1\times\mathbb A^1$ except itself land out of $V\times V$.