When did David hope to see the Lord?
Psalm 17:15
15 As for me, I will behold thy face in righteousness: I shall be satisfied, when I awake, with thy likeness. KJV, ©1769
David hoped to see Yavheh When he awoke, the awakening being a reference to the resurrection of the dead, since sleep is a reference to death.1
The prophet Isaiah wrote,2
Your dead will come back to life; your corpses will rise up. Wake up and shout joyfully, you who live in the ground! For you will grow like plants drenched with the morning dew, and the earth will bring forth its dead spirits. NET, ©1996
1 Psa. 13:3 cf. John 11:13
2 Isa. 26:19
Psalm 17 is prayer (v1, 4) of David for final vindication (v2). He seeks protection from God (v5-14).
The final verse has several elements that are answered elsewhere in the Bible.
Thus, there are numerous references here to the final resurrection of the saints when they awake from the graves. [Side note - the English "cemetery" come from the Greek "koimeterion" = a place of sleeping.]