"When you get that win out of the way, it just kind of gets everyone to breathe a little bit," outfielder A.J. Pollock said.
Miley (1-1) picked up the win, and there was no way the 18,974 in attendance could have seen that coming six batters into the game.
The Giants' first run came when Buster Posey singled home Angel Pagan. One out later, Brandon Belt gave San Francisco a 4-0 lead when he smacked a hanging breaking ball into the pool area in right-center for a three-run homer.
"I was kind of nibbling a little too much in the first inning and trying to make perfect pitches rather than just, 'Here it is,'" Miley said.
As he walked off the mound following the final out of the first inning, Miley covered his face with his glove and uttered some unprintable words. But by the time he reached the bench, he had composed himself.
"He's just matured a lot in situations like that," D-backs manager Kirk Gibson said. "These guys are good. If you don't get the ball where you're supposed to get it, they're going to pound you."
What also helped Miley's mood was the fact that his offense responded with two runs in the bottom half against Matt Cain.
Paul Goldschmidt extended his hitting streak to 23 games with an RBI double, and he came around to score when Martin Prado followed with a single to center.
"The guys answered right back," Miley said. "The offense did great job of kind of picking me back up. I knew if I just kind of held it right there then we'd have a chance to get back on top, and it worked out."
That it did. Miley would not allow any more runs and managed to last through the seven inning. After the Belt homer, he retired 15 straight before walking Posey in the sixth.
"He got in a groove and we couldn't do anything," Giants manager Bruce Bochy said. "He threw some inside pitches that our hitters were frustrated by, but what could you do? He settled down and got deep into the game, which is a credit to him after giving up four in the first."
Meanwhile, the offense continued to chip away.
In the fourth, the D-backs capitalized on the questionable use of a replay challenge by Bochy to pull to within 4-3.
Bochy used his replay challenge with one out and Pollock on first. Cain tried to pick Pollock off and first-base umpire Chris Guccione called Pollock safe. The call was upheld, meaning there was not enough evidence to overturn the call.
"It was so close, honestly," Pollock said. "I wasn't shocked he called safe. If he called out, I would've had a little reaction, but it was so close."
Gerardo Parra followed with a double to right to move Pollock to third. Posey then appeared to be crossed up by a Cain pitch, and the ball scooted away from him. Pollock tried to score, and it appeared that Cain tagged his foot before it hit home plate.
But home-plate umpire Eric Cooper called Pollock safe, and because Bochy was out of challenges, he could not ask for a review. And because it was before the seventh inning, neither could the crew chief, according to the rules.
"At home, that was just a weird play," Pollock said. "Everyone is saying I was out. I kind of did a kick stop and hop over the glove there, and I kept looking at the replay. I didn't feel a tag and I kept looking. It was a pretty gutsy call by the umpire, but I think he got it right."
Pollock and Parra were in the middle of another rally in the sixth, with Pollock driving in a run with a double and Parra scoring Pollock with a sacrifice fly to give Arizona a 5-4 lead.
Addison Reed worked around a one-out double in the ninth for his first save with the D-backs. It was a bounceback outing for the closer, who gave up a two-run homer to Posey on Monday night to give the Giants the win.