Django app taking around 24 seconds to load webpage after retrieving data from PostgreSQL database

I have a Django application where I'm querying a PostgreSQL database using raw SQL queries in my views.py file. Once I retrieve the data, I process it and send it to the index.html file. However, every time I load the webpage, it takes approximately 24 seconds to fully load.

Here's an overview of my setup:

I have a Django app configured to connect to a PostgreSQL database. In my views.py file, I'm using raw SQL queries to fetch data from the database using Django models. After processing the data, I pass it to the index.html template for rendering. I've added print statements in views.py to measure the time taken to retrieve and process the data. Additionally, I'm tracking the time it takes for the webpage to load using JavaScript in the DOM of index.html. Despite optimizing my SQL queries and processing logic, I'm still experiencing significant delays in webpage loading. I'm seeking guidance on potential reasons for this delay and strategies to improve the loading time of my Django application.

Any insights or suggestions would be greatly appreciated. Thank you!

Back to Top