In the first part of Psalms 31, David describes God as being a strong refuge. Now, the theme of the psalm is going to change. In verses 6-8, we start to see the second theme creek into the passage.
6 I hate those who cling to worthless idols;
I trust in the LORD.7 I will be glad and rejoice in your love,
for you saw my affliction
and knew the anguish of my soul.8 You have not handed me over to the enemy
but have set my feet in a spacious place.
Can start to see the second theme creek in? All though David is still speaking to God and how God had helped him, you start to see trouble and sorrow coming; my afflictions, anguish of my soul, enemy, etc. You didn’t see any of these words in the first theme of the psalm.
From verses 9-13, we see the second theme fully.
9 Be merciful to me, O LORD, for I am in distress;
my eyes grow weak with sorrow,
my soul and my body with grief.10 My life is consumed by anguish
and my years by groaning;
my strength fails because of my affliction, [a]
and my bones grow weak.11 Because of all my enemies,
I am the utter contempt of my neighbors;
I am a dread to my friends—
those who see me on the street flee from me.12 I am forgotten by them as though I were dead;
I have become like broken pottery.13 For I hear the slander of many;
there is terror on every side;
they conspire against me
and plot to take my life.
In the second theme, David is in the pit. Everything is going against him. He is weak and broken. So what is one to do when afflictions come? When sorrow and grief arise? When it feels like everyone has abounded you? We’ll see how David responded in the rest of the Psalm.