In 2014, the database also helped Brooklyn prosecutors convict another accused rapist, Avery Bovell. Two years after the attack, Mr. Bovell was arrested and questioned in connection with a commercial burglary. The police obtained a sample of his DNA from an object he touched, and it matched the DNA of one of two men the victim said had raped her. In June, Mr. Bovell pleaded guilty to first-degree criminal sexual act.

“Without having that resource, we would never have been able to identify one of the attackers in that case,” said Rachel Singer, the chief of the forensic science unit in the Brooklyn district attorney’s office.

Once a person’s genetic information has been put in the database, it can be a struggle to get it removed, lawyers said. Last year, the medical examiner’s office removed only seven DNA profiles from the database.

Take, for example, the case a Bronx man, Lamar, who asked that his last name be withheld to protect his privacy. In April 2018, detectives questioned him about a firearm they believed he had discarded and surreptitiously collected his DNA from a cigarette they had offered him, video of the interrogation shows.

When the charges against him were later dismissed, Lamar petitioned a judge to expunge his DNA from city records. He said he did not learn that detectives had collected his DNA from the cigarette until it was revealed at a court hearing. “I didn’t expect nothing like that,” he said.