Another explanation of Psalm Shir HaMaalot Chanukat HaBayit. This is what the verse (Job 41:3) means: "Who preceded Me, that I should repay?" Who thought in his heart to do a mitzvah before Me and I did not reward him for it? Who performed a commandment and I did not give him the reward before he even did it?

Who made tzitzit and I did not give him the reward before he made the garment? Who made a fence for his roof and I did not give him the reward before he built the house? Who gave charity and I did not give him the reward before he gave the coins? Whoever thought in his heart to do a mitzvah, but did not do it, I credit him as if he did it.

For David thought to build the Holy Temple and it is named after him, as it says, "A Psalm, a Song of Dedication of the House, for David" (Psalms 30:1).