Django admin inline causes timeout when there are large amount of inline data

I have a model and there are thousands of its instances.
On django admin, if I select one instance which has the largest amount of inlines(two inlines and there are hundreds of objects for each inline fields), the admin does not respond and times out finally.
For other instances, it does not happen because all the other instances have very less inline objects assocaited.
How can I resolve this problem?
Should I remove inlines from admin?

Please help me!

Thanks in advance.

I’d install the debug toolbar to help debug the N+1 queries you’re likely encountering as well as verify your performance optimization changes.

One way to improve performance without much effort, though at the expense of functionality is to use raw_id_fields.

Another way to improve performance is to override the form class with to apply filters on the field’s queryset. This assumes that filtering is even applicable for your project’s domain.

Thanks
I am trying to create a link to show inlines in a separate page.
And yes, I have autocomplete_field for those inlines and I think raw_id_fields might help.

Thank you. I will let you know once I resolve this.

Give the debug toolbar a try. It can help you identify some easy fixes via select_related and prefetch_related.