n 1st Samuel 22:22 we can find David as frustrated as he ever was in any circumstance. His aggravation surely included some introspective disappointment. However, this psalm indicates clearly that the bulk of David's anger was aimed at the worthless man named Doeg. Doeg was truly a self-serving, deceptive and opportunistic louse. He had no qualms about killing 85 of God's holy priests plus their wives and children (1st Samuel 22:18-19). So, even though David felt awful about being the excuse that Saul and Doeg had used in the execution of Nob, he made no excuses for Doeg. Of course, David surely couldn't have known that his passage through Nob would endanger the lives of everyone there. His thoughts had been mostly about self-preservation on that day (1st Samuel 21:1-9). But, in retrospect, how he wished that he hadn't passed through Nob... or that Doeg had not been there that day... or that he had foreseen the intentions of Doeg!
But, the past is called the past for a reason... and, David couldn't change the past. However, he certainly could speak concerning the future. That's where this psalm fits in. The same man who wrote the great confession of Psalm 51, had written Psalm 52 years earlier in angry imprecation. The primary reality that David exprressed several times in this prayer was the goodness of God. His logic went something like this, "Since God is good, evil men are in trouble." And, he was right, of course.
We have no reason to think that Doeg would have ever actually known what David had written about him, but that doesn't in any way at all take the edge off of David vehemence (Psalm 52:5). Of course, seeing that Psalm 51 and Bathsheba is fresh in our memory, we should thank God that, even though He knows our future, He doesn't judge us based on things that we haven't even done yet (Romans 9:11-12). David's "righteous indignation" was legitimately targeted at Doeg, despite the vices that were in David's future.