It is written in Tehillim (30/1) in the Mizmor that we say for the shir shell yom of Chanukah, "A song, Mizmor shir, for the dedication of the House by Dovid".
The Medrash in Yalkut Shemoni Tehillim (remez 713) asks two questions on this possuk. Dovid Hamelech did not build the Bais Hamikdash, his son Shlomo Hamelech built it. How can Dovid Hamelech sing a song for its dedication, Dovid Hamelech was no longer alive at the time of the dedication? Secondly, why is a "double expression", Mizmor and Shir, used to express that this perek is a song? The Medrash answers that one of the expressions refers to the Bais Hamikdash that stands in Yerushalayim and the second one refers to the Bais Hamikdash that stands in heaven.
Zera Shimshon asks, the Medrash's questions seem to be in the wrong order. The first question should have been why two words are used to express that this perek is a song, since this "double expression" is the first two words in the possuk. The second question should be how Dovid Hamelech could have written this Shir if he was no longer alive at this time, referring to the last word in the possuk. Why did the Medrash first ask about the end of the possuk and then about the beginning?
Zera Shimshon answers, the only reason it is difficult to understand why there are two expressions of song is because this Mizmor was written by Dovid himself. If it was written by someone else it would have been easy to understand the double expression.
How is this?
Zera Shimshon explains in light of what is written in Gemara Sotah (9A); Rav Chanina bar Pappa expounded: What is the meaning of the possuk, “Tzaddikim, sing joyously to Hashem, it is appropriate (naaveh) for the upright to praise"? Do not read the word naaveh as it is written, appropriate (naaveh) for the upright to praise" but rather read it as "nevei", meaning, your (you tzaddikim's) dwellings are worthy of praise. This refers to Moshe and Dovid whose enemies did not gain control and destroy their achievements.
The Gemara goes on to explain that both the Mishkan that Moshe built and an edifice that Dovid built were never totally destroyed by the enemies but were only sunk into the ground and buried.
Maharsha in Mesechta Sotah (9A) explains; the structure Dovid built that is being referred to is the Bais HaMikdash. Even though Dovid did not physically build the Bais Hamikdash it is attributed to him because "he prepared the gold and silver for it and bought the land on which it was eventually built". The gold and silver Dovid prepared were only used in the building of the first Bais Hamikdash, not in the building of the second one.
According to this, Zera Shimshon explains, if this Mizmor was written by someone other than Dovid we could explain the two expressions of song, mizmor and shir, are referring to the two Batei Hamikdash and the Psalmist is praising Hashem for each of them. However since Dovid was the one who built the first Bais Hamikdash and it was meant to stand forever the Medrash was bothered by why are there two expressions of song?
The Medrash answers, even at the time of the first Bais Hamikdash there were really two; one, the Bais Hamikdash on earth and one in Heaven!