This study performs extensive numerical simulations to investigate how the aspect ratio (AR) of a lid-driven cavity influences the onset of elastic instability and elastic turbulence and the subsequent mixed convective heat transfer rate inside it. To this end, we utilize the finite volume method based open source code OpenFOAM along with Rheotool to solve the mass, momentum, energy, and viscoelastic constitutive equations. We find that the dependency of the cavity AR on the heat transfer rate is highly complicated depending upon the values of the Richardson (Ri) and Prandtl numbers (Pr). At low values of Ri, the heat transfer rate continuously decreases with AR irrespective of the value of the Prandtl number and the fluid type, i.e., Newtonian or viscoelastic. The same trend is also observed at high values of Ri and low values of Pr. At these combinations of Ri and Pr, the heat transfer rate is always higher in viscoelastic fluids than in Newtonian fluids due to the presence of elastic turbulence in the former fluids. However, a different trend is observed at high values of both Ri and Pr. At this combination of Ri and Pr, the heat transfer rate increases with AR in Newtonian fluids, whereas it decreases in viscoelastic fluids. Therefore, at high values of AR, Ri, and Pr, the heat transfer rate is higher in Newtonian fluids than that in viscoelastic fluids despite the presence of elastic turbulence in the latter fluids. This is in contrast to the assumption that the elastic turbulence phenomenon always increases the rate of transport processes. A possible explanation for this behavior is provided in this study. Along with the heat transfer aspects, we also provide a detailed discussion on how the cavity aspect ratio influences the corresponding flow dynamics inside the cavity. In particular, we find that the onset of the elastic instability (and the subsequent elastic turbulence) phenomenon is delayed to higher values of the Weissenberg number as the cavity aspect ratio increases. This is in line with prior experimental studies reported in the literature.