This is a leap from God's nature to biblical text. Biblical text is not perfect, not always reliable, not always historical etc. If something in the Bible, especially in the Old Testament, does not seem moral, I would just ignore it.
The answer, in this particular case, is that the Psalmist's desire to see the children of his captors destroyed is an honest emotional expression--but one that we are not required to share. It's a much simpler biblical principle of description vs prescription. The Bible records people behaving badly, and saying terrible things, doing terrible things, and wishing terrible things--it would be bizarre to assume every recorded word, thought, or act is intended as a divine endorsement simply because it's recorded in the biblical text.
The historic Christian approach to the Bible doesn't allow for simplistic "good guys" and "bad guys"; the biblical "good guys" are constantly doing bad things, messing up, and God judges His own people; and at the same time the biblical "bad guys" often do good things, get things right, and God uses them as an example. The entire story of Jonah is a case study of this. Jonah was a prophet, a "good guy"; and the people of Nineveh are representatives of the very empire that destroyed the northern kingdom of Israel, the "bad guys"--but the whole story shows Jonah as a pretty miserable, awful person who is constantly disobedient--and in the end Nineveh is vindicated because of their repentance even as Jonah sulks in his misery. The bad guys end up "on top" in Jonah's story, because it's not about being a "good guy" or a "bad guy"--it's about justice and mercy. So when the Psalmist, a "good guy" desires the "bad guys" to suffer, including wishing to see the children of the "bad guys" have their heads dashed on rocks (a grotesque display of inhumanity toward humanity) we can sympathize with the plight of the Jewish people in exile without celebrating the wishes of the Psalmist who is revealing his own inward sinfulness and wrong-headedness; expressing a view that is out of alignment with the justice and mercy of YHWH.
Dividing the world between "good guys" and "bad guys" doesn't work from within the narrative structures of the biblical texts; and that itself should be a lesson we take away as we then look at and encounter the world. The world is complicated, messy, filled with human beings created in the Divine Image who, nevertheless, do bad things--there aren't "good guys" and "bad guys", there are only people. Messy, complicated, beautiful, ugly, human beings.
-CryptoLutheran