"the first genocide in recorded history"
The worldwide flood at the time of Noah as described in Genesis, chapters 6 to 8. From the description, it almost completely wiped out the human race, with the exception of Noah, his wife and sons and their wives.
The Passover incident described in Exodus chapters 11 and 12, in which all of the firstborn of all Egypt were slaughtered.
The conquest of Canaan, in which God ordered the Hebrews to completely wipe out the Canaanite people -- from the elderly to newborns and fetuses. This is described in the book of Joshua.
The near extermination of the tribe of Benjamin by the remaining 11 tribes, triggered by the serial rape and murder of a priest's concubine. See Judges, chapter 20.
I think the first real genocide in the Bible is Numbers Chapter 31. Other genocides were done by God, which doesn't really count.
[1] The LORD said to Moses,
[2] "Avenge the people of Israel on the Mid'ianites; afterward you shall be gathered to your people."
[3] And Moses said to the people, "Arm men from among you for the war, that they may go against Mid'ian, to execute the LORD's vengeance on Mid'ian.
[4] You shall send a thousand from each of the tribes of Israel to the war."
[5] So there were provided, out of the thousands of Israel, a thousand from each tribe, twelve thousand armed for war.
[6] And Moses sent them to the war, a thousand from each tribe, together with Phin'ehas the son of Elea'zar the priest, with the vessels of the sanctuary and the trumpets for the alarm in his hand.
[7] They warred against Mid'ian, as the LORD commanded Moses, and slew every male.
[8] They slew the kings of Mid'ian with the rest of their slain, Evi, Rekem, Zur, Hur, and Reba, the five kings of Mid'ian; and they also slew Balaam the son of Be'or with the sword.
[9] And the people of Israel took captive the women of Mid'ian and their little ones; and they took as booty all their cattle, their flocks, and all their goods.
[10] All their cities in the places where they dwelt, and all their encampments, they burned with fire,
[11] and took all the spoil and all the booty, both of man and of beast.
[12] Then they brought the captives and the booty and the spoil to Moses, and to Elea'zar the priest, and to the congregation of the people of Israel, at the camp on the plains of Moab by the Jordan at Jericho.
[13] Moses, and Elea'zar the priest, and all the leaders of the congregation, went forth to meet them outside the camp.
[14] And Moses was angry with the officers of the army, the commanders of thousands and the commanders of hundreds, who had come from service in the war.
[15] Moses said to them, "Have you let all the women live?
[16] Behold, these caused the people of Israel, by the counsel of Balaam, to act treacherously against the LORD in the matter of Pe'or, and so the plague came among the congregation of the LORD.
[17] Now therefore, kill every male among the little ones, and kill every woman who has known man by lying with him.
[18] But all the young girls who have not known man by lying with him, keep alive for yourselves.