A new study of nationwide housing prices shows San Diego’s market is on a par with San Francisco as the most unaffordable -- based on the relative salaries that would-be buyers need to qualify for mortgages.

Research by HSH Mortgage Services ranks Los Angeles next among 27 major metro areas in the gap between median home prices and median incomes.

In San Diego and San Francisco, the disparities raise red flags about economic stability.

“We have a robust economy -- a diversified, robust economy -- that demands employees, and those employees demand housing,” says Gary London, president of London Group Realty Advisors. "And not nearly enough housing is being built."

In an interview Thursday, London cited an undesirable mix of local housing stock coming on line.

For example, too much emphasis on multi-unit projects, as opposed to single-family "detached" dwellings that even millennials ultimately will opt for once they start having families.

Also, a shrinking land supply and regulations that drive up building costs.

The HSH study shows San Diego homebuyers need salaries of $109,000 to qualify for a monthly mortgage of $2,500 to meet the median home price of $590,000.

Market analysts say that sends income-stressed workers elsewhere and discourages business start-ups and expansions -- pushing companies toward other areas and states to protect their profit margins and growth potential.

Says Sean Karafin, director of police and economic research for the San Diego Regional Chamber of Commerce: "They might also know they don't have to pay as much in somewhere like Boston, and Denver because their employees don't have the same requirements when it comes to housing costs. So this is very real, and we lose jobs for San Diegans."

The most affordable major metro housing market, according to HSH, is Pittsburgh.

Prospective buyers there need a salary of $32,000 to qualify for a $756 monthly mortgage on a median home price of $140,000.

But those numbers have grown 17 percent since the first quarter of this year, so time may be of the essence for those now looking to buy.