What a difference a reelection bid makes.

The past two years, Mayor Vincent C. Gray has held his “State of the District” addresses downtown at the Sixth and I Historic Synagogue. This year’s event, scheduled for Monday, is set for Kelly Miller Middle School in Ward 7.

Why has the “One City Man,” after a long absence, decided to take his annual self-congratulatory, back-slapping affair east of the Anacostia River? The answer is simple: survival. Gray has little chance of capturing the Democratic Party’s mayoral nomination without significant turnout from Wards 7 and 8. So he is resorting to that age-old political tool: pandering. Staging the affair at Kelly Miller also might be characterized as exploiting the school’s success.

Was this the advice Gray received from Marion Barry (D-Ward 8) when the two chatted for five hours during the latter’s recent hospitalization? A former mayor and current Ward 8 D.C. Council member, Barry has mastered such tactics throughout his long, somewhat inglorious career.

Gray probably will cite the academic progress made at Kelly Miller, as documented by last year’s standardized test scores. Then he will ascribe improvements at the Ward 7 school to his administration, although for the first two years of his term, many advocates believed that education reform was on life support, with Gray missing in action. More important, many of the traditional public schools east of the river are among the city’s weakest.

If Wards 7 and 8 were used as indicators of the state of the District, folks could conclude that the city is in bad shape: The unemployment rate east of the river is stuck in double-digits. There are no upscale retail outlets and no white-cloth restaurants. There has been some economic development on the St. Elizabeths Hospital campus, but until the fence comes down, that energy can’t transfer to the adjacent Martin Luther King Jr. Avenue SE corridor. Eager to attract investors, a group of small-business leaders began working with D.C. Council member Jack Evans (D-Ward 2) more than a year ago to secure funding for improvement districts that would enhance public safety and cleanliness, making select commercial strips more attractive for new enterprises. Evans is one of seven candidates challenging Gray.

In 2010, strong voter turnout in Wards 7 and 8 catapulted Gray into the mayoral suite. He received 14,518 votes — 82.26 percent of the vote — in Ward 7 against incumbent Adrian M. Fenty, according to the D.C. Board of Elections. In Ward 8, Gray snared 10,502 votes (82.10 percent). But an illegal shadow campaign, allegedly financed by businessman Jeffrey Thompson, surely contributed much to that victory.

This time around, there won’t be an extra $653,000, to buy T-shirts, purchase banners and pay workers. There is an ongoing federal investigation of that 2010 operation. Gray said he did nothing wrong, and Thompson has not been charged with a crime.

Still, many earlier supporters have turned their backs on Gray. Some have been disturbed by guilty pleas from key lieutenants in the 2010 campaign, pleas that proved wrongdoing occurred. Other erstwhile fans have cited dissatisfaction with the administration’s delivery of services to poor and working-class communities.

This has made Gray vulnerable in his home base, providing an opening, albeit small, for his opponents, particularly council member Muriel Bowser (Ward 4), who won the straw poll conducted last month by Ward 8 Democrats. Last week, she was endorsed by The Post’s editorial board. This week, Emily’s List announced its support of her candidacy.

Bowser, hoping to capitalize on dissatisfaction with Gray and perhaps engaging in her own pandering, opened a campaign office on Good Hope Road SE. Andy Shallal, a restaurateur and mayoral candidate, also has an office in Ward 8.

Added to Gray’s troubles is the reality that his opponents, particularly Bowser, Evans and council member Tommy Wells (Ward 6), have solid support in their home bases, denying Gray a large share of voters west of the river. That means his lifeline is anchored in Wards 7 and 8.

Expect a lot of pandering beyond venues for speeches. In fact, this week, he announced a plan called “forWard 8, Investing in Our Future,” a $2.5 million business development and career training initiative, Gray said the program is “in direct response to issues identified at three Ward 8 Citizen Summits held in 2011 and 2012.”

What? It took two years to come up with crumbs?