web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch to SQL Rate Limi...
Power Apps
Answered

Patch to SQL Rate Limit Exceeded

(0) ShareShare
ReportReport
Posted on by 144

Hi All,

 

I have been building an app for a week now. It is an update on a previous app.

It seemed to be operating fine until recently it is now taking ages to patch into a DB and I am getting the following Error
App - SQL Error.PNGApp - SQL Error01.PNGApp - SQL Error02.PNG

Previously I manually added toggles onto a screen and then once the save button was clicked it would patch through to a database once.

 

I have recently changed my layout to use a gallery for each question then saved to a collection and then at the end a ForAll and Patch function to save the results in the collection to the SQL Database.

 

Is there a better way of doing this? Sometimes I may have up to 20 Questions on a page.

Here is my code:

 

 

 

ClearCollect(
 Answers,
 ShowColumns(
 AddColumns(
 QS_Questions.AllItems,
 "QuestionID",
 QS_Q_ID.Text,
 "Answer",
 QS_Q_Answer.Value
 ),
 "QuestionID",
 "Answer"
 )
);
ForAll(
 Answers,
 Patch(
 '[dbo].[answers]',
 Defaults('[dbo].[answers]'),
 {
 q_id: QuestionID,
 q_group: QS_CatID_Lbl.Text,
 answer: Answer,
 visitid: Var_VisitID
 }
 )
);
Patch(
 '[dbo].[q_notes]',
 Defaults('[dbo].[q_notes]'),
 {
 notes: QS_Notes.Text,
 q_group: QS_CatID_Lbl.Text,
 visitid: Var_VisitID
 }
);
Navigate(
 Category_Menu,
 Fade
)

 

Categories:
  • Verified answer
    Dawidvh Profile Picture
    1,346 on at

    @MrDannyHarry 

     

    ForAll will issue multiple patch commands to the SQL databases, each consuming network traffic and putting unnecessary load on the server. It seems like you are creating new items in SQL only, so an easy way to do it would be to collect all the records into the SQL tables. This will create new records in the SQL Table will all the items from the collection.

    Collect('[dbo].[answers]',Answers)

     

    If you want to update existing records, the key column from the SQL table has to be present in the collection, and if all the columns in the collection is present in SQL as well you could use the following to update records in batches

    Patch('[dbo].[answers]',Answers)

     

    You will see significant performance improvements on using the above methods, VS using ForAll.

     

    Dawid van Heerden

    Follow on Twitter: @davestechtips

    Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1

     

    **If you found this reply helpful, please give it a thumbs up and Accept as Solution to close the topic and make it easier to find for other people with similar questions.

  • MrDannyHarry Profile Picture
    144 on at

    @DavesTechTips 

     

    Cheers for this bud! 
    Just a quick question how do I map the fields in my collection to the SQL table?
    Or is it a case of making sure the column names match?

  • Dawidvh Profile Picture
    1,346 on at

    My pleasure @MrDannyHarry .

     

    The best would be to make sure that only the necessary fields are patched by using ShowColumns and DropColumns.

     

    Let me know if you don't come right 😉

  • MrDannyHarry Profile Picture
    144 on at

    @DavesTechTips 

     

    Hit a possible issue?
    I am pushing things into the database that aren't in the gallery.
    How can I add these into the Collection?

     

    Sorry if these are a bit stupid questions 😂

  • Dawidvh Profile Picture
    1,346 on at

    No problem. I You say 'things', are you saying columns or records.

     

    If you are saying colunms you can use AddColumns to add them to the collection.

     

    Patch('[dbo].[answers]',AddColumns(Answers,"NewColumnName","NewColumnValue"))

     

  • MrDannyHarry Profile Picture
    144 on at

    @DavesTechTips 

    So for example.

     

    The Gallery has the Question ID and Answer on it.

    Outside of the Gallery it has the group id and visit id.

     

    PULLED FROM GALLERYPULLED FROM GALLERYOUTSIDE OF GALLERY
    (THE SAME FOR EVERY RECORD THIS PATCH)
    OUTSIDE OF GALLERY
    (THE SAME FOR EVERY RECORD THIS PATCH)
    question_idquestion_answerq_groupidvisitid
    1true3123-123-123456
    2false3123-123-123456

     

    I'm not the best at explaining but hope this helps me explain.

  • Verified answer
    Dawidvh Profile Picture
    1,346 on at

    Hi @MrDannyHarry 

     

    I assume these are new records then.

     

    Try this one:

    Collect('[dbo].[answers]',AddColumns(Answers,"q_groupid",QS_CatID_Lbl.Text,
    "visitid",Var_VisitID))
    
    
    
  • MrDannyHarry Profile Picture
    144 on at

    @DavesTechTips 

     

    Very useful! much faster as well! THANK YOU!

  • Dawidvh Profile Picture
    1,346 on at

    That kind of feedback that makes my day, thanks @MrDannyHarry, glad I could help.

     

    Have a great day and weekend!

     

    Dawid van Heerden

    Follow on Twitter: @davestechtips

    Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard