According to NCRB, about 77% of prisoners in India are undertrials. and CrPc 167
https://indiankanoon.org/doc/1687975/
states that the maximum someone can be kept in Judicial custody is 90 days, or 60 days, depending on the gravity.
However, it appears from the report that many prisoners are detained beyond this period. According to another forum focused in Indian law , this is due to "charge sheet pending and prosecution requests of accused confronting prosecution witnesses."
https://tripakshalitigation.com/difference-between-police-custody-and-judicial-custody/
This says that if a police report is filed then the person can be detained up to a maximum of half the maximum period of imprisonment for the offence. What ? there was a recent post where someone was in pre trial detention for 1.5 years. is this legal ?