As the mayoral race heats up, the city got some sobering news: despite all the talk about the need for more housing, the city added fewer new units last year than it had in 2016.

San Francisco added 4,441 housing units in 2017 — a 12 percent decrease, compared to net additions in 2016. Last year’s additions, however, are well above the 10-year average of 2,745 units built each year.

Those numbers were released this month in the Planning Department’s “Housing Inventory,” an annual survey of housing production in San Francisco. It will be discussed at Thursday’s Planning Commission meeting.

As people continue to flock to San Francisco and prices continue to rise, housing advocates argue that the city is not building enough units to keep up with demand. Meanwhile, longtime residents fear that an influx of mostly market-rate housing projects will only make neighborhoods more unaffordable.

All told, San Francisco had 392,000 dwelling units by the end of 2017, compared to 387,600 at the end of 2016. Although fewer new housing units were built, the population increased.

By July 2017, San Francisco had added 8,260 residents over the previous year, making city’s total population roughly 884,363, according to the U.S. Census Bureau.

Meanwhile, the city saw a total of 4,500 new units in 2017, including 4,270 in new construction and 242 units through conversions and expansion of existing structures. (70 units were lost through demolitions, including the removal of illegal units, unit mergers, conversions and corrections.)

In 2011, the construction of new units hit an all-time low of 348.

Some 94 percent of the city’s new housing came from new projects totaling more than 20 units. The remaining 6 percent came from the new construction of projects totaling less than 19 units, with single-family homes accounting for 1 percent.

In spite of the overall downward trend in production, affordable housing production actually increased 83 percent in 2017, to 1,460, up from 802 in 2016. Those new affordable units made up 34 percent of last year’s new units. Eighty-five percent of those new units are affordable to “extremely low,” “very low,” and low-income households. Affordable units for seniors made up 3 percent.

A majority of the affordable units were contained in fully affordable projects, while 421 of the units, according to the report, were inclusionary — meaning they were mixed into a predominantly market-rate development — while 99 of the affordable units were considered “secondary,” or units added to an existing residential building.

While housing production lagged in 2017, the number of units authorized dramatically increased by 65 percent from 2016, as the Planning Department authorized 6,731 units in 2017. The department approved 4,059 in 2016. Approvals hit an all-time low in 2009, when only 752 units were approved.

San Francisco authorized 21 percent of the Bay Area’s housing stock, the third-most in the region. But Santa Clara County is the Bay Area’s biggest builder, having authorized 34 percent of the region’s total at 10,626 units last year. The second-highest number of unit authorizations came from Alameda County, with 8,523 units authorized, representing 27 percent of the region’s total.