cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Optimisation - unexpected behaviour with Collect

Just sharing an observation and suggestion for a change in the behaviour of the Collect statement.

 

In my app I have a number of Collect statements of the following form:

  Collect(
            '[ChemRec].[Recommendation]',
            Filter(
                colMyRecommendation,
                IsBlank(ID)
            )
        )

Where the filter returns no records, I would expect the Collect statement to effectively be ignored - to simply not run at all rather than run by saying 'Add 0 rows to the collection' and initiate communication to the datasource.

When stringing a few of these commands together, peformance took a realy hit. Ten such collections took over a minute to run when there was no data returned by the filters (some Collect statements were run with Concurrent but others are ineterdependent so must run sequentially).

By wrapping all the Collect statements within If statements that first check the local collection to see if it actually contains entries (as shown below) peformance increased dramatically and the same set of commands take around a second to run.

    If(
        CountRows(
            Filter(
                colMyRecommendation,
                IsBlank(ID)
            )
        ) > 0,
        Collect(
            '[ChemRec].[Recommendation]',
            Filter(
                colMyRecommendation,
                IsBlank(ID)
            )
        )
    );
1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps
Power Apps

Hi!

Thank you for the feedback! I have shared your feedback with the engineering team for further consideration.

Thanks!

View solution in original post

2 REPLIES 2
Power Apps
Power Apps

Hi!

Thank you for the feedback! I have shared your feedback with the engineering team for further consideration.

Thanks!

View solution in original post

Anonymous
Not applicable

Thanks for the helpful post @PaulD1 !

 

@Anonymous 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (7,892)