Since the atomic sizes of magnesium and calcium are smaller than that of sodium and potassium, calcium and magnesium form carbonates and hydroxides with higher lattice energies. Thus, they are only sparingly soluble whereas those of potassium and sodium are readily soluble due to low lattice energies.