NYPD Commissioner Bill Bratton deserves a quick salute for his decision this week to disband the agency's Demographics Unit, which dispatched undercover cops to spy on Muslims in mosques, cafes, stores and other gathering places throughout the region.

The brainstorm of a CIA agent working with the cops, the secret outfit caused more problems than it solved.

Renamed the Zone Assessment Unit after its activities were exposed, the group never produced a credible lead. But it did inflame widespread distrust of the police and made intelligence-gathering harder throughout the region.

And here's the weirdest part. The avalanche of data that the NYPD collected could have been compiled for the most part without the cloak-and-dagger routine.

Two of the unit's secret reports -- made public by The Associated Press -- illustrate the point:

"Egyptian Locations of Interest," compiled in 2006, found that Bay Ridge has the largest concentration of Egyptians in the city. After that comes Astoria, where an Egyptian influx was unfolding, undercover officers noted. The report went on to map -- precinct by precinct -- all of the city's probable Egyptian gathering places.

"Newark, New Jersey, Demographic Report," compiled in 2007, detected a large Nigerian population as well as several Nigerian mosques in New Jersey's largest city. But the NYPD cautioned that it had found an absence of halal butchers and ethic grocery stores in the Newark nabe.

advertisement | advertise on newsday

What a waste of resources.

As the unit was abolished, Mayor Bill de Blasio rightly pointed out that the administration has an obligation to put a police force on the streets that is respectful and fair regardless of race, ethnicity or religion. That's just as true when jihadists have the region in their crosshairs as it is in more peaceful times.

A dash of caution could mean fewer fiascoes, which often happen when police spy on neighborhoods without probable cause. The NYPD has plenty of law enforcement tools it can use to stay vigilant on terrorism. Most of them are more effective than the secret agent stuff.