Mobile app best practices
Learn about the best practices for building performant mobile apps.
Retool enables you to build highly performant apps that scale with your needs. As your Retool apps become more complex and interact with an increasing number of data sources, it’s important to monitor performance and make improvements where needed.
Follow these practices to identify, resolve, and prevent performance degradation and keep your apps operating as efficiently as possible.
Refer to the best practices guide for queries to learn more about writing performant queries for your data.
Investigate external factors
A significant amount of variability in app performance may be triggered by factors outside of Retool. These factors can greatly affect the speed of app loading, query runtime, and more. Check your infrastructure for the following common issues:
- Device CPU: This metric can vary between devices, such as a high-performance desktop and a low-performance laptop. Use Speedometer to check the responsiveness of your browser.
- Network speed: Use SPEEDTEST to test your network speed.
- Browser extensions: Injecting JavaScript and adding or modifying network requests can slow performance.
Retool recommends the following specifications for the computer that you use to edit apps:
- Processor: Intel Core i5 or an equivalent AMD processor.
- Memory: 16 GB RAM.
- Network Speed: 25 Mbps or higher (for smooth performance in data-heavy apps).
Utilize built-in performance tooling
Retool's Debug Tools have app-specific suggestions for improving performance or accessibility and addressing errors. In particular, the Performance tab surfaces suggested app optimizations directly related to performance. It’s a useful tool to diagnose common problems that degrade performance and view relevant app stats per page.
The following sections include more details about the recommendations that Retool surfaces through the Debug Tools Performance Tab, including explanations for each problem and suggested solutions.
Large payload size: Reduce query payload
Fetching large amounts of data can slow down load time and increase memory usage, which is amplified by slower networks or mobile devices.
To improve payload size, Retool recommends:
- Fetch only what you need: Reduce query size by selecting only the fields required for the UI. Avoid
SELECT *
or fetching unnecessary nested objects. - Paginate large datasets: Break large datasets into smaller chunks using pagination. This reduces payload size and improves perceived performance by loading data incrementally.
- Cache payloads: Cache frequently accessed data to avoid redundant large payloads. This minimizes network calls and improves response times. Refer to the Query performance best practices for more information.
- Query data server-side: When possible, aggregate data on the server side and return only essential data you need.
Keep payload size below the following thresholds:
- Moderate performance impact: 1.6MB (the amount of data that can be theoretically downloaded on a 3G connection while still achieving a Time To Interactive (TTI) of 10 seconds or less.)
- Severe performance impact: 3MB
Long query runtime: Optimize query calls
Slow queries can delay app responsiveness and block other operations. Query runtimes are highly dependent on factors like network speed, database resource limits, and more.
To decrease query runtime, Retool recommends:
- Optimize query calls: Review your query structure. Ensure you have appropriate indexing, avoid unnecessary joins, and fetch only what you need.
- Paginate large datasets: Instead of retrieving all records at once, fetch data in smaller chunks using pagination. This reduces the load on the server and improves the user experience.
- Cache frequently used data: Use caching to reduce redundant query execution for frequently accessed data, minimizing runtime for repeat queries. Refer to the Query performance best practices for more information.
- Break queries into smaller subqueries: If possible, split a complex query into smaller, more focused queries that can run in parallel to reduce overall wait time.
Keep query runtime below the following thresholds:
- Moderate performance impact: 3s
- Severe performance impact: 5s
Parallelizable queries
When queries are executed sequentially without needing to be, they introduce unnecessary delays and slow down page interactivity.
To parallelize queries, Retool recommends:
- Evaluate dependencies: Review your queries and determine which ones truly depend on each other. Queries without dependencies can be run in parallel.
- Use a controller query: Write a JavaScript query to act as a controller that triggers multiple queries in parallel and waits for them to finish using
Promise.all()
.
High page load queries: Run queries on demand
Running too many queries on page load can drastically increase the time for your app to become usable by overwhelming the server and browser, which blocks user interaction.
Retool flags this as a warning when there are high page load queries and your app’s Time To Interactive (TTI) is high, signifying a likely correlation between the two. If this does not apply to your app, feel free to ignore this warning.
To decrease the number of queries that run on page load, Retool recommends:
- Run queries on demand: Evaluate and configure non-critical queries to run only when triggered by user interaction (such as a button click) rather than automatically on page load. Refer to Query performance best practices for more information.
- Prioritize essential data: Focus on loading only the data that’s immediately necessary for the user. Defer fetching secondary data until after the initial render.
Keep page load queries below the following thresholds:
- Moderate performance impact: 7 and TTI > 5s
- Severe performance impact: 10 and TTI > 7s
Large client-side tables: Move operations server-side
Large tables with thousands of rows of data are expensive to render and sluggish with filtering, which is all done client-side on the browser.
To decrease client-side table size, Retool recommends:
- Use server-side pagination: Loading only the results for a given view and fetching more as users navigate through the table reduces load size and time to interaction.
- Sort and filter data server-side: Apply filters and sorting directly in the query to reduce the dataset before it reaches the client.
- Fetch only what you need: Limit your query to retrieve just the columns and rows you need. Avoid loading hidden or unused data.
Keep table size below the following thresholds:
- Moderate performance impact: 1000 rows
- Severe performance impact: 5000 rows