A hug needs to be 20 seconds long before the body starts to produce the “bonding hormone” oxytocin, which reduces the harmful physical effects on stress. There literally is a study for this.
Short hugs are probably useful though to change attitude towards others, e.g. feel not aggressive and it puts you into a friendlier mood.
Though when I hug now I make sure it lasts at least 20 seconds. To get maximum effect though, you should get at least 8 hugs of that sort per day. Hm, it’s either hugging the same people over and over again or building up a queue of potential huggers.
You need to be pretty friendly and trusting with someone to get such a close emotional bond that prolonged hugging produces. Also hugging is only really enjoyable if both parties really want to do it. You just can’t force others to hug you for 20 seconds and hold tight.