0

I've build this website https://hanjaba.com/ using django and supabase as the database. However the loading speed website seems to be very slow when it have to retrieve data from the database and loads the static pages quite fast. How can I increase the loading speed of the database?

Dhiman
  • 103
  • 1
  • 8

2 Answers2

1

Normally your requests could be slow due to inefficient queries, so you might want to determine the queries that are having slow responses: https://supabase.com/docs/guides/platform/performance#examining-query-performance

You can use the Slow Response Time template in the Logs Explorer and query performance report: https://app.supabase.com/project/_/logs/explorer https://app.supabase.com/project/_/reports/query-performance

They'll show you which queries are causing the slow-downs.

Also, make sure your Supabase project is ready for production by following the tips in this doc: https://supabase.com/docs/guides/platform/going-into-prod#performance.

It'll help you optimize your website performance.

Monica
  • 196
  • 1
  • 7
0

I would check on the very beginning those two things:

https://docs.djangoproject.com/en/4.2/ref/models/querysets/#select-related

https://docs.djangoproject.com/en/4.2/ref/models/querysets/#prefetch-related

both are related with problem called n + 1 - situation where you make many requests instead of just few.

Details are well described here: What's the difference between select_related and prefetch_related in Django ORM?

Although you didn't provide any details how you setup your database so that's what comes to my mind first.

Jaroszewski Piotr
  • 353
  • 1
  • 3
  • 11