Then my soul will rejoice in the LORD, exulting in his salvation. All my bones shall say, "O LORD, who is like you, delivering the poor from him who is too strong for him, the poor and needy from him who robs him?"
Sometimes it is hard for me to relate to the psalms that are basically prayers for avenging vindication. They have what to me seems to be a dark edge to them. For instance, David asks God to pick up weapons of war against David's enemies (Psalm 35:3). He prays for them to be shamed and dishonored (Psalm 35:26). It appears to be a graceless set of requests.
But the text is also a clear list of how much David's enemies worked against God and His Law. These people exploited the poor for personal gain (Psalm 35:10). They went after David out of sheer hatred (Psalm 35:7). They lied about him (Psalm 35:11). They were without a sense of God's justice (Psalm 35:12). They enjoyed David's pains and difficulties, mocking him in his needy hour (Psalm 35:15-16). They rejoiced at his sorrows (Psalm 35:19). They hated peace (Psalm 35:20).
So David was not harboring a personal grudge or vendetta when he asked for God to vindicate him before his foes. Instead, he was asking for God to judge their sin justly... for the reality was that their sins had real consequences. That puts all this vindication prayer into proper perspective. God would be magnified when sin had its consequences clearly seen in the world of humanity. David wanted God to be great and the Law to be respected when sin was judged. That is a good thing.