Have you ever noticed that David began Psalm 139 with the statement that the LORD had searched him (past tense) and knew him, then ended it with a request for God to search him again?
“O LORD, You have searched me and known me. You know my sitting down and my rising up; You understand my thought afar off. You comprehend my path and my lying down and are acquainted with all my ways.” [v1-3 NKJV]
“Search me, O God, and know my heart; Try me, and know my anxieties; And see if there is any wicked way in me and lead me in the way everlasting.” [v23-24 NKJV]
Did David think God forgot? Did he think God suddenly could not remember what David was like, his thoughts, his path and his ways? No, David knew God was well aware of his inner most being.
When David asked God to search him at the end of the psalm, He was asking God to reveal to David what was in his own heart. David asked God to show him those anxieties and doubts that plagued him, to reveal to him his sin. His cry was to know if there was anything in him that displeased his LORD, anything that would lead him away. Then once shown, David asked for God to lead him away from sin and in the path of righteousness.
Jesus said we are to pray daily, “lead us not into temptation ….” In other words, “Our Father, lead us away from anything in us that would take us away from You, any anxiety that would cause us to doubt Your loving kindness, any temptation of the world that would overwhelm our devotion to You. Amen”