PITTSBURGH -- The Arizona Diamondbacks have a lot of ground to make up if they are going to get to the postseason.
Martin Prado hopes that Saturday's 20-hit outburst was a step in the right direction.
The Diamondbacks won for the fourth time in five games. They entered the day 8 1/2 games behind the Los Angeles Dodgers in the NL West and six games behind the Cincinnati Reds for the second wild card.
"I feel like this is the beginning of what we should do from now on," Prado said. "I feel like everybody contributed. We're hoping to keep having this offense all the way through the end of the season.
"Being realistic, it's not going to be like this every day, but I liked the way we prepared for the game then everybody had good at-bats."
Prado's 11th homer of the season capped a six-run third inning against All-Star Jeff Locke and put the Diamondbacks ahead 8-0. Prado has driven in 13 runs in his past 10 games.
"It's just the way baseball goes," Prado said of his RBI surge. "I'm on a hot streak right now. You might go a month and not get an RBI. I just want to ride the streak as long as I can."
Goldschmidt's 30th homer came in the ninth and tied him with Pittsburgh's Pedro Alvarez for the National League lead. Alvarez hit his 30th earlier in the game.
Goldschmidt and Didi Gregorius each had three of the Diamondbacks' 20 hits.
Gregorius, a rookie shortstop, had gone 2 for 29 in his previous eight games.
"A lot of times you can tell how a guy is going to do in the game by his batting practice," Arizona manager Kirk Gibson said. "Didi didn't really have a set pre-game routine until today. He's finally found a routine that works and you saw the results. I think it's going to make a big difference for him."
Trevor Cahill (4-10) earned his first win since May 17. He went five innings and allowed four runs and seven hits. He was activated from the disabled list before the game. He had been out since July 1 with a bruised right hip.
After going 0-6 with a 7.91 ERA in his previous eight starts, Cahill struck out four and walked one.
"It felt like my debut all over again," Cahill said. "It was a weird feeling, like I hadn't done this before. I'll take the win, enjoy the great offensive support and then work on some things so I'm better in my next start."
Alvarez hit a three-run home run and Starling Marte added a solo shot for NL Central-leading Pittsburgh in the third inning, enabling the Pirates to cut the lead to 8-4.
Locke (9-4) allowed eight runs and 10 hits in 2 2/3 innings while walking three and striking out two. He is winless in his past four starts and gave up more than three runs for just the second time in his past 18 starts.
"Today was a reality check for me, absolutely," Locke said. "Any start like that is a reality check. You set your standards high, you set your goals high and you're disappointed when you don't reach them. I wasn't sitting there pouting about it, though, when I came out of the game. It's just the nature of the game to occasionally have a day like this."
Prado's home run with two outs in the third put Arizona ahead by eight and Locke was removed after Goldschmidt followed with a single. Goldschmidt's hit was the seventh in a row by the Diamondbacks in the inning, tying a club record.
Gregorius doubled in the first run of the third and Cahill, who was hitting .063, followed with a two-run single.
The Pirates, who have dropped six of eight, cut the deficit to 8-5 in the sixth when Russell Martin doubled and scored on Tabata's single.
However, Joe Thatcher came on and struck out Walker with the bases loaded to end the threat. Thatcher has inherited four bases-loaded situations this season and has not allowed a run.
Arizona added four runs in the eighth inning on pinch-hitter Jason Kubel's two-run single, Nieves' sacrifice fly and Gregorius' RBI single. Goldschmidt's homer in the ninth gave the Diamondbacks a season high in runs.
"Thatcher's strikeout was really big," Gibson said. "Even though the game was 15-5, it was a close game. They had a lot of pressure on us. People are going to look at score and say it was a blowout, but it was far from that. That's a good team over there and they kept coming at us."
The series concludes Sunday with Arizona LHP Wade Miley (9-8, 3.63) facing Pittsburgh RHP Charlie Morton (4-3, 3.79). ... The Diamondbacks optioned RHP Chaz Roe to Triple-A Reno to open a roster spot for Cahill. ... Arizona C Miguel Montero, who has been on the DL with a strained lower back since July 29, began an injury rehab assignment with the rookie-level Arizona League Diamondbacks on Saturday. ... The Pirates are hopeful RHP Jason Grilli, who has been on the disabled list since July 23 with a strained right forearm, can begin throwing off a mound by next weekend. Grilli has converted 30 of 31 save opportunities.