cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Responsive Resident
Responsive Resident

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
Highlighted

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
Highlighted
Power Apps
Power Apps

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.

Highlighted

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?

Highlighted

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

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

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,965)