It doesn't take a fancy study to tell you that San Francisco is densely packed. A trip through Chinatown on Muni or a peek at the thousands of tiny apartments that dot the city is enough to let anyone know that San Franciscans are living in increasingly close quarters.

But it does take a study to rank the city as the second-densest metropolitan area in the country - right behind our perpetually jealous East Coast stepsister New York City. And it turns out that density is apparently a very good thing.

According to "Measuring Sprawl 2014," a national study released Wednesday, when a city is more densely stacked with people and buildings, its residents have increased health and safety, better chances of upward economic mobility and lower transportation costs.

Also, the denser the city, the longer people live - a factor mostly due to a lower risk of fatal traffic collisions. While dense urban environments do have more car accidents, fewer of them result in fatalities according to the report, which was compiled by Smart Growth America, a Washington, D.C., coalition of groups advocating for city planning solutions,.

"For the average American with a life expectancy of 78 years, this translates into a three-year difference in life expectancy between people in a less compact versus a more compact county," the report's authors wrote.

Enter San Francisco.

Indexed by looking closely at four factors - development density, land use mix, street accessibility and activity centering - the city by the bay had a score of 194.28, just a smidge behind list-topper New York, which scored 203.36. And for those keeping tight score, San Francisco actually outscored New York in both the land-use mix and activity-centering categories measured in the study.

Making the top 25

Other notable Bay Area cities on the list include San Jose, ranked 24th in the country, and Oakland right behind it at No. 25.

Beyond avoiding deadly car accidents, the benefits reaped by people who live in cities with higher density include lower rates of obesity and diabetes, as well as lower blood pressure on average, the report said.

It's also cheaper to get around in cities that are more compact. The study found that people who live in dense areas have more transportation options, many of them cheaper than driving or even free.

"Transportation is a lot better here," said Conrad Marsi, who recently moved to North Beach from Long Island, N.Y. "You don't need a car here. They really just get in the way."

Children born in dense cities are more likely to climb the economic ladder as well, the study found. For every 10 percent increase in a city's index score there is a nearly 5 percent increase in the likelihood that a child born into the bottom 20 percent of income distribution will ascend to the top 20 percent.

Gabriel Metcalf, executive director at SPUR, an urban policy nonprofit in San Francisco, said the city has done a good job planning for growth, but the job is far from complete.

Good planning

"We've protected our walkable street grid and we've done a good job of removing some of the highways," he said. "We've been really good in some of the neighborhood planning efforts."

Among the planning successes, he said, are the reconfiguration of the intersection at Market and Octavia streets and the Transbay Transit Center.

But, unsurprisingly, housing still remains a tremendous hurdle that the city has yet to clear, Metcalf said.

"There are appropriate ways to create new housing," he said. "For downtown, that might mean high-rises. When you get to the outer neighborhoods, we need to be looking at secondary housing options like in-law units."

Coincidentally, the city's Board of Supervisors addressed that very subject Tuesday, passing legislation that, if eventually made final by the mayor, would authorize more in-law units. Meaning more density.