i know that x-rays are produced when a beam of high energy electrons hits a metal anode but why does that work better than when that same beam hits glass (like in the Crookes tube)?
But this is not the only way to generate x-rays. The other is via bremsstrahlung process where the electrons generate the EM radiation because they are being slowed down. This is where it is relevant to the OP's question, i.e. why is it more efficient to generate x-rays with a metal anode.When an energetic electron hits an atom it can knock out a core electron. Then one of two things can happen:
(i) An electron from a higher shell can fall into the vacancy in the lower shell, accompanied by the emission of an X-ray photon.
(ii) An electron from a higher shell can fall into the vacancy in the lower shell, while another outer electron is expelled from the atom (Auger electron).
The quantum yield of X rays increases with atomic number; light elements give mostly Auger electrons and heavy elements mostly X rays. The crossover is somewhere around zinc (Z = 30). Thus glass, containing mainly Si and O, will give a lower yield of X rays than a heavier metal, such as iron or tungsten.
Thus much I know from my acquaintance with SEM. Why things are that way round, I don't know.