The D-backs (35-26) now lead the defending World Series champion Giants by 3 1/2 games in the National League West.
"Where do you want to start?" D-backs manager Kirk Gibson asked the assembled media at his postgame news conference.
How about starting right here? Before Goldschmidt's big at-bat and just after Willie Bloomquist worked Affeldt for a key walk, Giants pitching coach Dave Righetti went to the mound for a long discussion. The point was to pitch carefully to Goldschmidt with the .199-hitting Miguel Montero on deck.
For the evening, Goldschmidt already had grounded into two double plays and struck out against Giants starter Matt Cain.
"Affeldt is as tough on righties as he is on lefties," Goldschmidt said. "He's not a left-handed specialist. He comes in there and pitches a whole inning. I had a feeling they were going to come at me. I just wanted to get a good pitch to hit, whatever it was, and be ready to hit it. It ended up being a fastball."
Right over the plate.
"It was a dumb pitch, dumb location, dumb selection," said Affeldt, who took the loss and is now 1-2. "Stupid. I didn't want to throw it there. I take full responsibility. The loss is on me."
Giants manager Bruce Bochy had his choices in that situation, although his usual right-handed setup guy Santiago Casilla is on the disabled list because of a knee injury. Bochy could have brought in closer Sergio Romo for a four-out save opportunity. He also had right-hander Jean Machi warming up. He stuck with Affeldt and paid the price.
"Yeah. I don't know what you want me to say," Bochy said. "He made a mistake and it left the ballpark. [Goldschmidt] is having a great year, he's had a knack for doing that, and it's our bad."
Gibson wasn't about to second-guess Bochy for staying with a left-hander against his right-handed slugger, who was 0-for-5 against Affeldt going into that at-bat.
"I'm mean, I make my decisions and he makes his decisions," Gibson said. "He's won two world championships. I don't think I'm going to tell 'Boch' what he's doing right or wrong. I think he's been pretty damn good and a guy I look up to and respect. He's a guy I learned a lot from and I'm privileged to be able to talk to him about a lot of things. Just observe. He knows what he's doing."
The game began as a battle of starting pitchers with the Giants holding a 1-0 lead heading into the bottom of the eighth with Cain still on the mound. D-backs left-hander Patrick Corbin barely missed on a chance at improving to 10-0.
The Giants scored their lone run in the seventh on singles by Pablo Sandoval, Brandon Belt and Gregor Blanco. Blanco's single to center drove in Sandoval from third.
Corbin, still 9-0, allowed seven hits, striking out four and walking none, and the D-backs improved to 12-0 this season when Corbin starts. He was replaced by Brad Ziegler after allowing a double to Marco Scutaro with one out in the eighth inning. Corbin threw 101 pitches and his ERA dipped to 1.98. Heath Bell worked the ninth and recorded his 11th save.
For the Giants, the veteran Cain pitched one of his better games of the year, holding the D-backs to a run on four hits with three walks and four strikeouts. He came out in the eighth after A.J. Pollock beat out an infield single to open the decisive inning.
"It was a low-scoring game with not too many runs," Corbin said. "I felt bad giving up a run there, but Goldy came through as he has all year. I'm just glad he's on my team and he put a good swing on it there."