SAN FRANCISCO (AP) -- Ryan Vogelsong has felt so good lately that it reminds him of his successful run over the previous two seasons. He just wants to keep building on that feeling. Vogelsong threw eight sharp innings for his first victory in three months, helping the San Francisco Giants beat the Pittsburgh Pirates 4-0 on Sunday. ''I thought I was settling in over my last four innings against the Red Sox and I just stayed with what's working,'' said Vogelsong, who pitched seven solid innings in a no-decision against Boston on Tuesday. ''I didn't throw the ball well before I got hurt and wasn't finding anything comfortable. The goal is to finish strong and I feel like I'm on the way to that.'' Pablo Sandoval had two RBIs as the Giants won their second straight to split the series with the Pirates. Buster Posey and Joaquin Arias each drove in a run. ''It was exciting to drive in those runs,'' Sandoval said. ''The team needs wins. I lost 20 pounds and I'm moving around better too.'' Vogelsong (3-4) allowed two hits, struck out five and walked one in his first win since May 20 against Washington. He had been sidelined by a broken pinkie finger on his right hand. The right-hander used his longest outing of the season to lower his ERA to 2.55 in four starts since coming off the disabled list on Aug. 9. ''That's one of the best pitched games we've had,'' Giants manager Bruce Bochy said. ''It was fun to watch. He put on a show on the art of pitching. He was comfortable throwing any pitch at any time.'' A.J. Burnett (6-9) pitched 7 1-3 innings for Pittsburgh, giving up four runs and eight hits. He fell to 2-3 in 10 starts since returning from the DL. Sandy Rosario finished the three-hitter for San Francisco's 11th shutout. The Pirates, who are tied with St. Louis for the NL Central lead, have been shut out nine times this season. Vogelsong, who recorded his first decision since coming off the disabled list, faced just two over the minimum, retiring eight of the final nine batters he faced. ''It just seemed whatever we were looking for, something else came out of his hand,'' Pirates manager Clint Hurdle said. ''We just didn't square him up a whole lot throughout the game. We just had a couple of opportunities. We weren't able to adjust or complicate things for him.'' Burnett was nearly as good until running into trouble late. He retired six straight after Posey's RBI single and then retired six straight again before Posey's single in the eighth. The Giants scored their first run in the third. After two outs, Gregor Blanco walked and Brandon Crawford singled ahead of Posey's single. The Pirates had two runners reach as far as second against Vogelsong, and just once with less than two outs. A double play started by Posey in the sixth prevented another runner from moving up. After Jordy Mercer was hit by a pitch, the reigning MVP pounced out of the box to grab Burnett's bunt and start a double play. ''You anticipate a bunt there and I felt like it was close enough that I had a shot,'' Posey said. ''At that point it's all or nothing. There can't be any hesitation.'' Vogelsong said the play changed the inning. ''You're just hoping to get the one out at second,'' he said. ''Getting two outs was a big play.'' Posey also threw out a runner trying to steal. The Giants put the game away with three more runs in the eighth. Posey and Hunter Pence singled around an infield groundout and Sandoval drilled a triple into the deepest part of the ballpark. Arias added an RBI double against Tony Watson. NOTES: Giants RHP Matt Cain will join LHP Jeremy Affeldt in Arizona to continue rehabbing. Cain is expected to begin throwing again this week while Affeldt will throw a bullpen session on Monday. ... LHP Barry Zito (4-9, 5.63 ERA) will start for the Giants on Monday night at Colorado. He's 0-3 with an 11.20 ERA in his last four starts. ... LHP Jeff Locke (9-4, 3.01 ERA) gets the start for the Pirates when they begin a series against Milwaukee on Tuesday night. He's 1-2 in seven starts since the All-Star break. ... Pirates OF Andrew McCutchen has hit safely in 10 of his last 11 games against the Giants. ... Posey collected RBIs in back-to-back games for the first time since July 19-20. ... The Pirates are 5-0-2 in series of at least four games. ... The Giants finished 11-23 against the NL Central, the second-worst record of any NL team against that division.