Using strain to uncover the interplay between two- and three-dimensional charge density waves in high-temperature superconducting YBa
2Cu
3O
yUsing x-ray diffraction on underdoped YBa$_2$Cu$_3$O$_y$ under uniaxial pressure, this study uncovers direct evidence of competition between short-range 2D charge density waves (CDWs) and a long-range 3D CDW, while finding no signatures of discommensurations or pair density waves. The interplay among 3D CDW, 2D CDWs, and superconductivity is qualitatively reproduced by a nonlinear sigma model with strain included, demonstrating strain tuning as a probe for competing orders.