| Ijlal Monawwar
In my experience of developing PowerApps, there are several ways to optimize the performance of a Canvas App, including:
Delegation: Delegation allows our app to take advantage of the capabilities of the data source, such as filtering, sorting, and grouping, rather than performing these operations locally within the app. Here is an example of using the Filter function to delegate a filter operation to the data source:
Filter(Customer, Name = "Lionel Messi")
Limit Data Connections: Limiting data connections will reduce the number of transactions performed between the data sources as each connection requires a lot of CPU resources, memory and network bandwidth. Limiting them to under 30 connections is ideal.
Caching data: Caching data allows your app to store frequently used data locally, reducing the number of round trips to the data source and improving the performance of your app. You can use the Set and Get functions to implement data caching in your app. Here is an example of how to cache data in a Canvas App. We can use collections to store and process data locally instead of retrieving data from the data source each time.
// Set the cache
Set(MyCache, Filter(Customer, Name = "Lionel Messi"))
// Get the cache
MyCache
Using Concurrent function: In a Canvas App, the Concurrent function allows you to run multiple asynchronous functions in parallel, rather than running them sequentially. This can be useful when you want to perform multiple tasks concurrently to improve the performance of your app.
Here is an example of how to use the Concurrent function in a Canvas App:
Concurrent(
UpdateContext({myVar1: "Task 1"}),
UpdateContext({myVar2: "Task 2"}),
UpdateContext({myVar3: "Task 3"})
)
In this example, the Concurrent function is used to run three tasks in parallel: updating the value of myVar1, myVar2, and myVar3. These tasks will be run concurrently, rather than sequentially, improving the performance of the app. We can also set up the concurrent function on the OnStart property of the app, to load data simultaneously.
Concurrent(
ClearCollect( ProductNames, '[ProductTable].[Name]' ),
ClearCollect( CustomerNames, '[CustomerTable].[Name]' ),
)
It's important to note that the Concurrent function does not return any values, so it is not suitable for use in expressions that require a return value. Instead, it is used to perform multiple tasks concurrently.
Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.