cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
BrianHFASPS
Level 8

Performance: Patch(LookUp()) vs. UpdateIf()? Inside a ForAll

Just wondering if there is a performance difference between a Patch with LookUp inside vs. an UpdateIf? It seems like they should be similar by wasn't sure.

Patch(
            '[dbo].[Daily Activity Attendance]',
            LookUp(
                '[dbo].[Daily Activity Attendance]',
                DailyAttUID = 'User ID' && AttendanceDate_x0020_String = TodayVar
            ),
            {
                ActivityOneSigninTime: Text(
                    Now(),
                    "[$-en-US]hh:mm:ss"
                ),
                ActivityOne: 'Attendance Class Name Dropdown'.Selected.ActivityID
            }
        )

or

UpdateIf(
    '[dbo].[Daily Activity Attendance]',
    DailyAttUID = 'User ID' && AttendanceDate_x0020_String = TodayVar,
    {
        ActivityOneSigninTime: Text(
            Now(),
            "[$-en-US]hh:mm:ss"
        ),
        ActivityOne: 'Attendance Class Name Dropdown'.Selected.ActivityID
    }
)

Also the Patch seems to work within a ForAll but the UpdateIF gives an error about table vs. record.

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Performance: Patch(LookUp()) vs. UpdateIf()? Inside a ForAll

ForAll(Patch()) is my preferred method here. If that is what you already have, I'd stick with it.

View solution in original post

3 REPLIES 3
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Performance: Patch(LookUp()) vs. UpdateIf()? Inside a ForAll

Hi @BrianHFASPS

Am I correct that you are deciding between ForAll(Patch()) vs. UpdateIf?

 

UpdateIf is able to update data for multiple records at a time that match the conditions. But today, UpdateIf is non-delegable, meaning it may not reach the records beyond 500 records.

 

The ForAll(Patch()) pattern is able to update one record at a time. But because it is one at a time (yet simultaneous), it is slower than the UpdateIf method. However, it is able to pinpoint the precise record to change. It is also delegable (provided that the conditions you use in the lookup are).

 

Spoiler
UpdateIf(
    '[dbo].[Daily Activity Attendance]',
    DailyAttUID = 'User ID' && AttendanceDate_x0020_String = TodayVar,
    {
        ActivityOneSigninTime: Text(
            Now(),
            "[$-en-US]hh:mm:ss"
        ),
        ActivityOne: 'Attendance Class Name Dropdown'.Selected.ActivityID
    }
)

I am thinking that you're getting a mismatch for table/record with UpdateIf because of the part in red. When you're using ForAll, you are really accompanying your actions with the respective record that it's working on from an array. But UpdateIf is not running against another array. 

 

Let me know if this is the case.

BrianHFASPS
Level 8

Re: Performance: Patch(LookUp()) vs. UpdateIf()? Inside a ForAll

I don't think I can refactor my ForAll(Patch()) as a simple UpdateIf(). Also I would have issue eventually with delegation since my table is adding 100 records a day.

 

You are exactly correct with the error you highlighted. Is there a way to workaround that?

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Performance: Patch(LookUp()) vs. UpdateIf()? Inside a ForAll

ForAll(Patch()) is my preferred method here. If that is what you already have, I'd stick with it.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 454 members 6,017 guests
Please welcome our newest community members: