Recently, one of our clients reported slower load times within the application we developed. In this article, we'll explore strategies for enhancing the performance of your FlutterFlow application without requiring app modifications or redeployments. We'll focus on applications that leverage Supabase as a backend.
In a previous article, we explored developer standards for optimizing the data layer of SQL database-based applications, particularly focusing on scalability. If you haven't read it, you can access it here.
If your application utilizes Supabase as a backend, providing your SQL database (Postgres), and you've implemented some of the previously mentioned standards, we'll explore a straightforward approach to enhance application performance using out-of-the-box tools available within the Supabase Dashboard.
As our application matures and gains more active users, the database accumulates more data. This increased data volume can lead to longer query times, impacting the overall responsiveness of our application.
The Supabase Dashboard offers an 'Advisor' tool that can help identify potential performance improvements within your database. You can access this tool from the main menu of your Supabase project dashboard. The Advisor tool includes two sections one for 'Security Advisor' and the other for 'Performance Advisor.' For the purpose of this article, we'll concentrate on the latter.
The Advisor tool categorizes its recommendations into three levels: 'Errors,' 'Warnings,' and 'Info.' You can review these recommendations in order of importance and apply the suggested changes or fixes to your database.
The Advisor tool can suggest creating database indexes for frequently used queries. Indexes help the database locate data more efficiently by avoiding full table scans. In this case, you can simply click on the “Create an Index” button and follow the instructions:
Search the column where you want to apply the index:
Leave the default selected index type and click on the “Create Index” button:
After that, you can review or search for a specific database index in your dashboard in the “Database” section “Indexes”:
It's advisable to create indexes during periods of low application activity, as the indexing process can be resource-intensive, especially for large tables. This can temporarily impact database performance. As shown in the following graph, we can observe a significant increase in GPU usage when we create the index.
Row Security Levels (RSL) can sometimes impact performance, especially when rules are implemented to restrict access based on authenticated user permissions. The Performance Advisor can suggest optimizing an RSL rule by adding a SELECT statement to the beginning of the condition. This caching mechanism can significantly improve performance. You can click the “View policies” button to open the RSL.
And you can add the SELECT statement to the beginning of the condition:
A crucial tip is to carefully review the 'Resolve' section within each suggestion. This provides detailed guidance and additional information to help you implement the optimal solution.
By implementing the recommendations from the 'Performance Advisor,' we can optimize our database and, consequently, enhance the overall performance of our application without the need to directly modify our FlutterFlow application or deploy new versions. As shown in the image below, we can observe a significant reduction in the application's startup time.
I highly recommend integrating Firebase tools like Crashlytics, Performance Monitoring, and Analytics into your Supabase-backed application. These tools provide valuable insights into your application's behavior, helping you identify and address performance issues.
To keep this post concise, we'll conclude here. However, I encourage you to explore other valuable sections within the Supabase dashboard, such as 'Security Advisor' and 'Query Performance,' for further optimization opportunities and security improvements.
Interested in a free app review?
Schedule a call