The UK system of immigration detention is shaming. The extent to which it is hidden, by design, from public view is among its most pernicious characteristics. There are 2,000-3,000 people in detention awaiting deportation at any one time; around 27,000 in total last year. This summer there were two suicide attempts each day. While the sheer misery evidenced by such statistics is discomfiting, it must be faced if anything is to change.

The UK is the only EU country that detains people indefinitely. Home Office guidance states that detention should be used sparingly and for the shortest possible period, but this week’s Guardian investigation reveals a sample of 188 detainees on 31 August last year, among whom the median stay was four months, with the longest nearly three years. In July, Sajid Javid, the home secretary, committed to reviewing the use of indefinite detention; this week his department repeated his pledge. It must now explain when and how changes will be implemented. Locking people up with no end in sight is wrong.

That 56% of our sample were officially classified as “at risk”, because they had suffered torture, had had suicidal thoughts or were unwell, is alarming. In a recent report on vulnerable detainees, the former prisons ombudsman Stephen Shaw described the length of time people were detained as “deeply troubling”. Uncertainty about the length of detention was singled out, in a custody watchdog report, as a factor in the distress of one 28-year-old man who killed himself. When concerns of this kind have been raised about such a vulnerable group of people, it is clear that external scrutiny is called for. Judicial oversight is the sensible answer.

While just over half of our sample had served a prison sentence, the rest had committed no crime. This means they arrived in detention either from a reporting centre, having been taken into custody after having an asylum application rejected, or following enforcement action such as an immigration raid. One woman spoke to the Guardian of her fear of a fellow detainee; last year’s BBC Panorama programme, filmed undercover at Brook House near Gatwick, similarly highlighted the inappropriateness of housing criminals alongside people who have done nothing wrong. Alternatives to detention such as community supervision, already relied on in Sweden and Canada, should be piloted as soon as possible.

The use of detention has declined by one-third in the past three years, and the government has acknowledged some of the terrible mistakes it made in deporting, or refusing re-entry to, members of the Windrush generation. But the overwhelming impression created by our snapshot of a day in the life of the detention system is of hardship and failure that extends far beyond the 10 centres’ walls. A majority of adults in our sample had lived in the UK for at least five years. Almost a third had dependent children in the UK, meaning children as well as parents living with the threat of separation. One detainee who was finally granted asylum told us that he did not expect the trauma of detention to ever leave him. More than half of those detained are never deported; in 2017-18 the Home Office paid out £3m in compensation.

Immigration enforcement is difficult. The man who told us his experience was a “death sentence” is not unique. When people fear being forced to leave the country they have sought to make their home, they feel desperate. That is why it is so important that the system which deals with them is both efficient and humane. At present, the arrangements presided over by Mr Javid appear to be neither.