# Django serialization taking more time to serialize data

**URL:** <https://forum.djangoproject.com/t/django-serialization-taking-more-time-to-serialize-data/36359>\
**Category:** Forms & APIs\
**Created:** [November 12, 2024, 4:19am UTC](https://forum.djangoproject.com/t/django-serialization-taking-more-time-to-serialize-data/36359 "2024-11-12T04:19:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgolawar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rgolawar/32/25125_2.png) [@rgolawar](https://forum.djangoproject.com/u/rgolawar)\
**Post date:** [November 12, 2024, 4:19am UTC](https://forum.djangoproject.com/t/django-serialization-taking-more-time-to-serialize-data/36359/1 "2024-11-12T04:19:30Z")

</div>

Hi,

My application uses Python==3.9, Django==2.2.28, Django rest framework==3.12.4 and google app engine. please consider, I have a “test” model which has nearly 40 fields. I am trying to serialize 1000 datastore objects using Django(rest framework) serializer but it is taking around 5-6 seconds. Any suggestions why it is taking more time? I did analysis on database query and query is taking less time i.e. in milliseconds but while serializing the query data it’s taking more time.  
Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![boxed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/boxed/32/11975_2.png) [@boxed](https://forum.djangoproject.com/u/boxed)\
**Post date:** [November 12, 2024, 9:31am UTC](https://forum.djangoproject.com/t/django-serialization-taking-more-time-to-serialize-data/36359/2 "2024-11-12T09:31:17Z")

</div>

Have you looked at it in a profiler?

---

<div class="post-metadata">

**Author:** ![jhuni-shukla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jhuni-shukla/32/25132_2.png) [@jhuni-shukla](https://forum.djangoproject.com/u/jhuni-shukla)\
**Post date:** [November 12, 2024, 11:08am UTC](https://forum.djangoproject.com/t/django-serialization-taking-more-time-to-serialize-data/36359/3 "2024-11-12T11:08:10Z")

</div>

the issue may be due to handling of related fields try to use select\_related( for foreign key/OneToone) and prefetch\_related(ManytoMany)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 12, 2024, 11:47am UTC](https://forum.djangoproject.com/t/django-serialization-taking-more-time-to-serialize-data/36359/4 "2024-11-12T11:47:39Z")

</div>

Welcome @rgolawar !

Side note: While there are people here who will try to assist you with your issue, this forum is **not** an official support channel for the Django REST Framework. You may get faster or more detailed assistance from one of the resources listed in the [Support](https://www.django-rest-framework.org/#support) section of the docs.

You are also likely to get better answers here if you post your model and view involved in this process. What you have posted doesn’t really provide enough information to do anything other than make guesses about what the problem _might_ be.
