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.

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.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 49 members 4,933 guests
Please welcome our newest community members: