Canvas Apps are user-friendly, low code applications that allow developers to quickly design an app layout and connect it with various data sources. However, even with the ease-of-creation, performance can be an issue if not properly optimized.
When optimizing Canvas Apps, developers should focus on:
- Optimizing data connections: Canvas Apps tend to be data-intensive. Having too many data connections can significantly slow down the app. The best practice here is to reduce data connections as much as possible and only use as many connections as the app truly needs.
- Reducing controls: More controls mean more power and memory required for the app to run smoothly. To optimize performance, developers should try to streamline the number of controls in the app. It’s about keeping what’s needed and removing what is not.
- Decreasing image sizes: Heavy images slow down app performance, as each image requires individual server requests.
- Efficient navigation: In an app with multiple screens, users usually navigate back and forth between them. If the screens are too many or too heavy, performance can be affected.
Pre-Loading Data
One way to improve Canvas App performance is pre-loading data. This practice involves fetching data up-front rather than retrieving it on-demand during the app operation. Pre-loading data reduces wait time for users, resulting in a smoother experience.
The ‘OnStart’ property of an application is a perfect place for pre-loading data. This property executes every time the app launches, making it an ideal time for datapulls.
For example:
ClearCollect(CollectionName, DataSource)
The code fetches all records from the DataSource and stores them in local CollectionName to be used within the application, speeding up the loading process.
Query Delegation
Query delegation enhances performance by shifting the processing load from the Canvas App to the data source. When a data source can process queries, it’s known as delegation. In the bigger picture, delegating tasks results in the faster running of applications as the processing load is distributed rather than being concentrated in one place.
Delegation is particularly advantageous for larger datasets. Microsoft Power Platform has a data row limit. If the data surpasses the limit, not all records will be scanned, potentially resulting in incomplete databases. But with query delegation, the data source processes the queries, eliminating the risk of non-scanned records even in large datasets.
Here’s an example of a delegable function:
Filter(DataSource, Column>Value)
It means that the processing of this data will be handled by the data source, instead of processing it in Power Apps.
To optimize Canvas Apps performance, it is also vital to keep aware of non-delegable functions and queries that won’t be processed in the source. Understand how to manage them correctly to avoid potential pitfalls.
In conclusion, thoughtful design choices involving efficient use of data, control elements, images, navigation, pre-loading data, and query delegation can significantly optimize Canvas App performance, which is a critical knowledge segment for the PL-400 examination. Developers need to understand these optimization concepts and apply them appropriately to create effective and efficient Canvas applications.
Practice Test
True or False: Pre-loading data in a canvas app can significantly improve the app’s runtime performance.
- 1) True
- 2) False
Answer: True
Explanation: Pre-loading data, especially when dealing with a large amount of data, helps to fetch the data before it is actually needed in the app. This reduces the amount of time that the user has to wait for data to load while using the app.
What is query delegation in the context of PowerApps?
- A) The process of letting the data source, rather than the app, perform certain operations
- B) The process of assigning tasks to multiple workers
- C) The process of letting the app perform all operations
- D) None of the above
Answer: A
Explanation: Query delegation in PowerApps allows the data source to perform the operations such as filtering, sorting, and aggregating data, rather than the app. This optimizes the performance and speed of the app.
True or False: Query delegation in PowerApps is supported for all types of data sources.
- 1) True
- 2) False
Answer: False
Explanation: Query delegation in PowerApps is not supported for all types of data sources. There are only certain data sources like SharePoint, SQL Server, Common Data Service, which support this feature.
Which of the following is NOT a way to optimize canvas app performance?
- A) Minimizing data load
- B) Efficiently using collections
- C) Using non-delegable queries
- D) Pre-loading data
Answer: C
Explanation: Non-delegable queries can cause performance issues as they require more data to be retrieved from a data source and can result in incomplete data retrieval if the data exceeds PowerApps’ limit of 2000 records.
True or False: Delegating operations to a data source can be inefficient.
- 1) True
- 2) False
Answer: False
Explanation: Delegating operations can be very efficient – it allows filtering, sorting, and other operations to occur on the data source rather than on the app. This reduces the amount of data that the app needs to download and process.
What is the primary reason to preload data in a canvas app?
- A) To reduce data trip
- B) To reduce app size
- C) To make the app look better
- D) All of the above
Answer: A
Explanation: Preloading data in a canvas app helps reduce data trips. Preloading ensures that once the app is loaded, there are fewer back-and-forths between the app and the data source, making the app much quicker and more efficient.
Select all that apply. Which of the following are benefits of query delegation?
- A) Increases app loading times
- B) Reduces the amount of data that needs to move between the app and the data source
- C) Limits the need for in-app data processing
- D) Allows for real-time data updates
Answer: B, C, D
Explanation: Query delegation reduces data movement between the app and the data source, which optimizes performance. Additionally, it reduces in-app data processing and allows real-time data updates as operations are performed directly on the source.
True or False: Pre-loading data does not impact the performance of the canvas app.
- 1) True
- 2) False
Answer: False
Explanation: Pre-loading data can significantly enhance the performance of the canvas app by reducing the need for back-and-forths between the app and the data source after the app is loaded.
What is the main disadvantage of non-delegable data operations?
- A) They can slow down the application
- B) They can result in incomplete data retrieval
- C) They are not supported by many data sources
- D) All of the above
Answer: D
Explanation: Non-delegable data operations can slow down the app, result in incomplete data retrieval if the data exceeds PowerApps’ record limit, and are not supported by many data sources.
True or False: Frequent and unnecessary data round trips should be minimized to optimize the performance of a canvas app.
- 1) True
- 2) False
Answer: True
Explanation: Unnecessary data round trips can slow down a canvas app’s performance. Reducing these trips, for example by pre-loading data, can help optimize app performance.
Using collections efficiently in a Canvas app…
- A) Can improve performance
- B) Has no effect on performance
- C) Has a negative impact on performance
- D) None of the above
Answer: A
Explanation: Collections in PowerApps canvas app reduce the amount of time taken to perform operations, hence improving the performance of the app.
True or False: Delegable data operations protect against incomplete data retrieval.
- 1) True
- 2) False
Answer: True
Explanation: Delegable data operations delegate data processing tasks to the data source rather than the app, preventing the app from hitting its record limit and resulting in incomplete data retrieval.
Which of the following functions are delegable in PowerApps?
- A) Sort
- B) Filter
- C) Search
- D) All of the above
Answer: D
Explanation: PowerApps supports the delegation of a number of functions to the data source for improved performance, including the Sort, Filter, and Search functions.
True or False: Pre-loading data in a canvas app can only be implemented for small scale apps.
- 1) True
- 2) False
Answer: False
Explanation: The principle of pre-loading data can be applied to a canvas app of any scale. For apps dealing with significant quantities of data, pre-loading can be crucial to optimizing performance.
A non-delegable operation…
- A) Can retrieve all records from a data source
- B) Is performed by the data source
- C) Is performed by the app
- D) None of the above
Answer: C
Explanation: A non-delegable operation is performed by the app itself, rather than the data source. This can lead to performance issues if the app hits its record limit and can result in incomplete data retrieval.
Interview Questions
What is query delegation in the context of optimizing a canvas app’s performance?
Query delegation is a concept in Power Apps where the workload of processing data is shifted from the app to the data source. This can significantly enhance an app’s performance by reducing the resources required by the app to perform various operations on data, especially large data sets.
What are the benefits of pre-loading data in a canvas app?
Pre-loading data in a canvas app can improve the app’s performance and responsiveness by having data ready when it’s needed. Users don’t have to wait for the app to fetch the data when performing tasks, creating a smoother, more gratifying user experience.
Can all data sources in Power Apps be used with delegation?
No, not all data sources in Power Apps support delegation. A list of data sources that do support delegation can be found in Power Apps documentation.
What is the default delegation limit in Power Apps, and can it be changed?
The default delegation limit in Power Apps is 500 items, but it can be increased up to a maximum of 2000 items in the app settings.
What are the possible results if a canvas app’s data queries exceed the set delegation limit?
If the data queries in a canvas app exceed the set delegation limit, the app will only work on the top ‘n’ records of the data source, where ‘n’ is the delegation limit.
What are delegation warnings in Power Apps and how to handle them?
Delegation warnings in Power Apps are flags that tell you when a function or a formula you are using might not work correctly with large data sets due to its inability to delegate processing to the data source. One can replace non-delegable functions or formulas with delegable ones to handle these warnings.
Why is it important to minimize the number of server requests in a canvas app?
Minimizing the number of server requests is pivotal to optimize the performance of a canvas app. It reduces latency, enhances the responsiveness of the app and provides a smooth user experience.
How can the use of collections help optimize the performance of a canvas app?
Collections in Power Apps are local tables of data that can help reduce the number of server requests as the data is stored and can be processed within the app. This can help enhance the app’s performance.
How can you optimize a large Image or Media file within a Canvas App?
Large Images or Media files can be optimized for performance within a Canvas App by resizing them to the maximum required resolution or by using an Azure CDN.
Is it possible to disable the auto-playing of media in a canvas app to improve performance?
Yes, you can disable the auto-play properties of video and audio controls in a canvas app, thus improving load times and enhancing its performance.
What is the significance of the Concurrent function in Power Apps?
The Concurrent function in Power Apps allows for multiple formulas to run at the same time, rather than sequentially. This leads to a reduction in total time taken, thus enhancing the app’s performance.
How does using Variables and Contexts function help in optimizing canvas app performance?
Using Variables and Contexts allows you to store and manipulate data within the app, thereby minimizing requests to the data source significantly, which can improve performance.
How does maintaining a simple DOM contribute to canvas app performance?
A simple DOM (Document Object Model) leads to faster load times, simpler code and less memory usage, all of which contribute to better canvas app performance.
How does deferring the calculation of non-visible components increase canvas app performance?
By deferring the calculations of non-visible components, a canvas app only expends resources when it’s necessary. This lessens needless computations, increasing performance.
How do you ensure that unnecessary network calls are not made when using the LookUp function?
To prevent unnecessary network calls when using the LookUp function, ensure that the LookUp function is not being used unwittingly in a loop. Each iteration in the loop could cause a separate network call, effectively slowing down the app. Instead, use one LookUp function to retrieve the necessary data and store it in a variable for reuse.