Hi,
My PowerApp has no delegation warnings yet when I run the azure sql profiler I can see the queries are always getting all the records rather than what I have requested. Take the following formula as an example :
ClearCollect(LocalAsbestosItem,Filter('[dbo].[AsbestosItem]',ReportDraftID = GalleryReportList.Selected.ReportDraftID));
When I check the azure sql profiler I can see that its not delegated as I can see the SELECT TOP 300 * ... (I have my data row limit set to 300) in the query :
This is happening in various places in my PowerApp and is making it slow in some parts. How can I fix these sort of problems as I thought the PowerApp designer is supposed to flag these delegation issues ?
Solved! Go to Solution.
Hi @Assurity
To clarify, ClearCollect will collect no more than the number of rows that are specified in the data row limit setting.
Strictly speaking, ClearCollect is delegable. That is, Power Apps will correctly 'delegate' the query expression to SQL Server, and SQL Server will filter the data as required. In your SQL profiler trace, the SELECT TOP 300 should be accompanied by a WHERE clause that matches records based on ReportDraftID.
If ClearCollect were not delegable or if we were using a non-delegable query expression, we would see no WHERE clause in SQL profiler, and Power Apps would carry out the filtering client-side.
Hi @Assurity
ClearCollect will not retrieve in one go, more than the number of records that are specified in the data row limit setting. That's the reason for this behaviour.
If you were to set the Items property of a gallery to directly to your formula, the expression would be delegable. That is, the gallery will load all of the records in batches as you scroll down the gallery.
Filter('[dbo].[AsbestosItem]',ReportDraftID = GalleryReportList.Selected.ReportDraftID)
Hi @timl
Thanks for your response. The App is designed to work offline, so I am loading the data into collections first, and using the collections in my galleries and other controls. Are you saying that ClearCollect does not support delegation and will just go for the maximum number of the data row limit setting ?
Hi @Assurity
To clarify, ClearCollect will collect no more than the number of rows that are specified in the data row limit setting.
Strictly speaking, ClearCollect is delegable. That is, Power Apps will correctly 'delegate' the query expression to SQL Server, and SQL Server will filter the data as required. In your SQL profiler trace, the SELECT TOP 300 should be accompanied by a WHERE clause that matches records based on ReportDraftID.
If ClearCollect were not delegable or if we were using a non-delegable query expression, we would see no WHERE clause in SQL profiler, and Power Apps would carry out the filtering client-side.
Thanks @timl . That makes some sense to me. I did some further testing and could see what you described happening on my PowerApp. This should not affect the performance of my app as the number records I need are within the data row limit setting.
User | Count |
---|---|
158 | |
99 | |
83 | |
77 | |
59 |
User | Count |
---|---|
196 | |
173 | |
103 | |
93 | |
89 |