“A canticle of David, when the house was built after the captivity.” So far as the literal sense is concerned, the heading points to the time when the temple at Jerusalem is known to have been refurbished by Zerubbabel, son of Salathiel, after it had been leveled to the ground by a hostile band of Chaldeans. But since he says nothing of this kind in what follows, and since the headings of psalms are never at variance with their content, it remains for us to investigate it in the spiritual sense. A destroyed house is built up when a soul following the captivity of sin begins to return to an understanding of the truth through the generosity of the Lord. This house, which is the universal church in which Christ dwells, is always raised up on living stones, because every day it gains increase in building from its confessors and does not cease to be built up until the number of the predestined is attained at the end of the world. We must store this psalm in our minds as the second of those proclaiming the first and the second coming of the Lord.
Their horses were six hundred and thirty-six, etc. A mule is born from a donkey and a mare, a she-mule from a horse and a she-donkey. Hence, among the people who ascended from captivity, the animals, which facilitated their journey, are also listed; both their number and that of the people are indicated in the prophetic book. For certainly there are many in the Church who are either slower in understanding or even carnal in mind, who nevertheless humbly submit to the spiritual teachers and diligently support the burdens of fraternal necessity. These, along with the other elect, are delivered from the confusion of diabolic captivity and strive towards the walls of the celestial city. Their number, as well as that of the more perfect ones, is preserved intact in the eternal memory of the inner witness. Thus, from the perspective of the holy universal Church, it is said to God: "Your eyes saw my imperfection, and all were written in Your book" (Psalm 139). And in another psalm: "You will save both men and animals, Lord; as You have multiplied Your mercies, O God" (Psalm 36). But immediately concerning the more perfect ones: "The sons of men shall hope under the shadow of Your wings" (Ibid.), etc.
[AD 585] Cassiodorus on Ezra 2:64-70