We investigate the relationship between grain boundaries and the optical properties of AlN-rich AlGaN/AlGaN quantum wells (QWs). The samples under investigation were grown by MOCVD on c-sapphire. Each sample consists of a 5 period QW structure, with the AlN concentration of the quantum barrier (QB) set at a nominal value of 73%, and that of the QWs varying between 35% and 65%, giving 257-284 nm band edge emission. We excite the samples below and above the bandgap of the quantum barrier using 244 nm and 229 nm second harmonic lines of an Ar+ laser. The grains are observed to have strong excitonic confinement characteristics, which causes a deviation from the usual ‘S-shape’ photoluminescence (PL) temperature dependence. This tendency progressively intensifies with increasing grain boundary area. PL spectra show that the QWs have a dominant effect on the energy of the near-bandedge peak at temperatures below 150 K, whereas the confinement properties of the grains come to bear beyond 150 K. Room temperature cathodoluminescence hyperspectral imaging using an environmental SEM is used to compare emission from inside grains and near the grain boundaries. While our results show that the grain sizes have a strong modulating effect on the extent of confinement, we observe that the grain boundaries have no effect on the peak intensities of the AlGaN/AlGaN samples, which suggests that there is a distinction between the low-energy shoulder usually observed in photoluminescence spectra and lateral compositional inhomogeneity, which causes grain growth. We investigate the carrier dynamics in the QW using excitation below and above the QB bandgap and power dependent time-resolved PL spectroscopy.