Can the use of wastewater for irrigation be a more efficient way to allocate water resources for competing uses?

Can the use of wastewater for irrigation be a more efficient way to allocate water resources for competing uses? If yes, how do we deal with microbial and heavy metal toxicity of wastewater?