PHOENIX -- Brandon McCarthy chalked up his recent struggles to mechanical flaws.
The result was one of his best outings of the season.
After a shaky first inning, the 6-foot-7 McCarthy (3-8) allowed only four runners over his final six innings. It was his first win since he beat San Diego on May 28. His other victory was a shutout at Miami on May 18.
"I felt I carried my weight, and nice to see a positive result," McCarthy said. "I never felt that strong this season and went back to watch video from before I went on the disabled list last season. I saw some mechanical issues, made a few adjustments and am satisfied with the results."
McCarthy lasted only into the third inning in his previous start, a 10-7 loss to the Reds. He allowed seven runs and eight hits in 2 1/3 innings.
Goldschmidt stretched his NL-leading RBI total to 103 with his first triple of the season and a groundout. He has the most RBIs for an Arizona hitter since Luis Gonzalez drove in 104 in 2003.
After Will Venable and Alexi Amarista opened the game with singles, Yonder Alonso hit a grounder wide of first. Goldschmidt fielded the ball and threw to second to force Amarista, but shortstop Didi Gregorius' throw to first was wide and beyond McCarthy, who was covering the bag. Venable scored the unearned run.
However, that was all the Padres would get against McCarthy and Eury De La Rosa, who pitched a perfect final two innings.
"The story was we couldn't get any runs," Padres manager Bud Black said. "I thought (starter Tyson Ross) was fine."
Between the first inning and when he left the game, McCarthy allowed a one-out single in the third to Venable, a two-out single in the fourth to Chase Headley and a two-out single to Ross (3-7) in the fifth. He hit Jedd Gyorko with a pitch with two out in the sixth.
"I didn't think I threw all that bad in the first inning," McCarthy said. "I just followed (catcher) Miguel Montero's lead and didn't shake him off one time."
Although his pitch count was 58 through four innings, McCarthy was more efficient in the later innings. He threw 93 pitches in seven innings.
Adam Eaton was hit by a pitch to open the fourth, and Goldschmidt hit a twisting drive into the right-field corner that hit off the fence.
Martin Prado then followed with a sacrifice fly to give Arizona a 2-1 lead. Prado's grounder to third with the bases loaded in the sixth was booted by Headley. Two more runs scored to make it 4-1.
Prado has hit in 11 of his past 12 games for a .361 average and has driven in 19 runs in that stretch.
"I'm taking advantage of the situation," he said. "I had a difficult course over the first few months, and it's good to get going this way."
In the seventh, Goldschmidt grounded into a force play with the bases loaded, scoring Aaron Hill.
Former Arizona right-hander Ian Kennedy faces his former teammates for the first time Tuesday night. In his four starts with San Diego, Kennedy is 2-1 with a 3.20 ERA. The Arizona starter is undecided. ... The Padres had won five of their previous six games at Arizona. ... Padres CF Reymond Fuentes made his major league debut and went 0-for-3 with a strikeout. ... The crowd of 16,871 was the Diamondbacks' smallest at home this season.