Pragmatically, it is not generally a wise course.
Primer on operant conditioning (the ostensible purpose of spanking):
How Does Operant Conditioning Work? - General Psychology
Physical punishments are likely to have very unpredictable effects on a young child's psychology that can lead to social dysfunction and unintended or unforseen difficulties for the child going forward processing stimuli in social reality.
The research so far tends to support the conclusion that well-tailored rewards (especially with young children, 8 and under) are not only more effective, but less potentially harmful -especially when applied by parents who are not trained to recognize the
function of a behavior.
From 12 years onward you learn differently | e! Science News
(Younger children are more likely to misunderstand or incorrectly process punishments than they are rewards, and this changes with age.)
Kids Who Get Spanked May Have Lower IQs
(spanking may contribute to lower intelligence)
My own hypothesis is that social reality and its rules for acceptable behavior are very complex and for a healthy functioning adult, must be acquired with some significant amount of nuance and a broader picture of how consequences play out in these socially complicated arrangements that make up most of life for a human operating in social reality. Spanking works on a different instinctual level that reinforces an un-nuanced understanding of cause-effect and social consequence.
It probably isn't prudent unless you live in relative isolation from the rest of society.