As a player, I'm in two games with wildly different session timing.
Game #1: strictly scheduled for four hours every other week. We rarely go over or under by more than 15 min (though the first 15-30 min is usually social time as we feed ourselves). Although we joke around a bit, we hold to our objectives and prioritize getting things done
Game #2: s roughly every other weekend, date and time not set until one of us gets around to it, and usually runs at least seven hours. During this time we're drinking, taking 15-minute breaks, joking around a lot and going off on social tangents, sharing videos, etc.
As a GM, neither of these is exactly my ideal for running game, so I try to find a balance.
I run mostly for a lot of the same players from the jokey/social crew in Game #2. At first they were surprised at how short my sessions were, but also that we were getting more done per session than in our seven-hour game. Here's how I found the balance: I see that we as a crew get bored when we're not meeting in-game objectives and milestones, which makes us even more likely to entertain ourselves with socializing, thus a feedback loop where we spend even more time in the session to try to get things done, and more time socializing. However I also find the socializing to be a valuable source of input for me as a GM, because my guys' way of thinking out loud is to riff on things, associate a scene to a funny video they saw, etc. I need to build in time for the socializing because that's how I learn what they're picking up on in the world, which NPC traits have an impact on them, etc. But I also need to build in time to achieve things in game.
Now, how I try to manage that balance is a topic for a different thread, but that's how I have determined five hours is my ideal! We're lucky to have at least enough flexibility in our schedules right now that we can make the time.