This first section speaks of God as the righteous Judge in whom the afflicted may hope.
9:1-2 In view of the aspects of Yahweh's character that he would yet describe, David said he would thank God wholeheartedly. He would announce His extraordinary works publicly, rejoice in Him, and sing the praises of the Most High.
9:3-6 Here are the reasons for David's delight. God had vindicated him by punishing the nations that had opposed him as God's vice-regent. God had given a thorough victory. The cities of some of his enemies and even their names had perished suggesting the complete annihilation of these groups, perhaps tribes or smaller nations. Behind his own throne David saw Yahweh ruling in heaven and granting him the victory.
9:7-10 In contrast to those whose names had perished (v. 5) the Lord's name would abide forever because He will rule forever as a righteous Judge. In view of this those most in need of a righteous Judge to give them justice, namely the afflicted and the oppressed, may flee to Him in their distress. The concept of God as a refuge occurs often in the psalms. A "stronghold"(Heb. misgob, also translated "refuge"and "fortress") is a high place of security and protection. When David fled from Saul he often took refuge in strongholds of various kinds (1 Sam. 23:14, 19, 29). However, he regarded the Lord Himself as the best of these.
9:11-12 David closed this pericope of praise (vv. 1-12) by appealing to the afflicted and oppressed to praise God and testify to others about God's care of them. The NIV and marginal NASB readings "avenges bloodshed"(v. 12) more clearly express David's thought then "requires blood"(cf. Gen. 9:5).