Federer, playing in his first official match after a six-month injury break, slammed 46 winners in a 7-5 3-6 6-2 6-2 defeat of the Austrian qualifier on the first day of the Australian Open
"This year hasn't been so tough yet, last year was tough," Federer joked during a court-side interview at Rod Laver Arena in Melbourne.
Earlier in the day, top seeds Angelique Kerber and Andy Murray were both given a workout in the Australian heat as they overcame tough Ukrainian opponents to reach the second round.
"It's nice to be playing normal tennis again on a center court like this, it's beautiful," Federer said.
"Couldn't be happier I am here now. It was a long road and I made it. I'm in the draw which is a beautiful thing and I hope I can stick around for a little bit. First rounds are never easy for anybody, just happy I live another day."
The former top-ranked Swiss, the winner of 17 majors including four Australian Open titles, and 2010 French Open semi-finalist Melzer first played each other when they were juniors.
Now both 35 years of age and recently having overcome surgery -- Federer on his knee a year ago and Melzer on his shoulder in 2015 -- the Swiss was in command for most of the match.
Firing off 19 aces and rushing to the net 24 times, Federer was at times so dominant, he even won 16 points in a row from 4-5 in the first set.
His concentration lapsed in the second set, which he lost despite leading 3-1.
He then quickly restored order as he won the next two sets in just under an hour with attacking play that had the crowd roaring with delight at times.
Stan's body shot
Competing in his 18th Australian Open, Federer faces another qualifier, 200th-ranked American Noah Rubin, in the second round.
Meanwhile on Hisense Arena, Swiss No. 1 and former Australian Open former champion Stan Wawrinka overcame a five-set scare against Martin Klizan, 4-6 6-4 7-5 4-6 6-4.
There was a controversial moment in the match, as reigning US Open winner Wawrinka drilled a blistering forehand into Klizan standing at the net which had the Slovak doubling up in agony.
Defending champion Kerber of Germany squandered a match point in the second set before battling past 51st-ranked Lesia Tsurenko, 6-2 5-7 6-2.
"First rounds are always tough," Kerber said in a televised court-side interview. "But I always enjoy it here."
Kerber's ascent to the top of the women's rankings started a year ago in Melbourne, when she came back from a match point down in the opening round to win the tournament.
She knocked 22-time major singles winner Serena Williams off the top spot after winning her second major of the season at the US Open in September.
Murray, who overtook defending Australian Open champion Novak Djokovic as the world No. 1 at the end of last season, overcame Illya Marchenko in three close sets.
Britain's Murray, seeking his first Australian Open title after five finals defeats, prevailed 7-5 7-6 (7-5) 6-2 against the 95th-ranked Marchenko as temperatures rose to as high as 30 degrees Celsius (86 Fahrenheit).
"I didn't move that well," Murray told reporters after the match. "That's how it felt anyway. But sometimes that can also be down to the conditions, as well.
"The ball's flying through the air a little bit quicker, so the ball is coming onto you faster than what it was the last few days. Maybe wasn't reacting as quickly as I would have liked."
Earlier, American Shelby Rogers -- world No. 52 -- pulled off the biggest shock of day one so far when she upset the fourth-seeded Romanian Simon Halep, 6-3 6-1.
Halep told reporters later on she had been struggling with tendinitis on her knee which hampered her movement.
Five-time Wimbledon winner Venus Williams, French Open champion Garbine Muguruza and men's fifth seed Kei Nishikori all moved to the second round.