This is a complex psalm with elements of complaint, imprecation and praise. As we often see in David’s writings, the final verses of his psalms deal with praise to his God.