The psalmist's deep desire for God arises from being far away from the temple as he remembers the past.
The verb translated as "longs" appears only here and in Joel 1:20 (meaning "cry out"). In both instances, it describes extreme thirst in a dry desert (see Psalms 63:1; 143:6; see also 84:2).