"And David built there an altar to the LORD, etc." (2 Samuel 24:25). Rabbi Tanchuma and Rav Bibi in the name of Rabbi Eliezer ben Yaakov: Israel is compared to sand. Just as with this sand, you dig a pit in it in the evening, and in the morning you find that it has filled up by itself, so too all those multitudes who fell in the days of David were replenished in the days of Solomon. This is what is written: "Judah and Israel were many, as the sand which is by the sea in multitude" (1 Kings 4:20). Rabbi Yehudah b'Rabbi Simon said: I did not hear it from the mouth of my father; his colleagues heard it from the mouth of my father. "And the LORD was entreated for the land, and the plague was stayed from Israel" (2 Samuel 24:25).
David's Altar and Israel Replenished Like the Sand
Midrash Shmuel 32:2
ויבן דוד שם מזבח לה' וגו' (שמואל ב' כ"ד כ"ה), רבי תנחומא ורב ביבי בשם רבי אליעזר בן יעקב נמשלו ישראל כחול, מה החול הזה את חופר בו גומא מבערב, בשחרית את מוצא אותה שנתמלאה מאיליה, כך כל אותן האוכלוסין שנפלו בימי דוד נתמלאו בימי שלמה, הדא הוא דכתיב יהודה וישראל רבים כחול אשר על (שפת) הים לרב (מלכים א' ד' כ'), אמר רבי יהודה ברבי סימון אנא לא שמעתה מפומיה דאבא, חבריה אינון שמענוה מפומיה דאבא, ויעתר ה' לארץ ותעצר המגפה מעל ישראל (שמואל ב' שם שם).