cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
nick9one1
Level: Powered On

Most efficient way to get data from on prem SQL to PowerAPP

I've created a simple powerapp that allows users to search an on prem sql table for information. 

 

It works fine but is very slow. The query takes about 30 seconds.

 

I've tried a couple ideas to make this faster, but none really work. 

 

The closest I got was to copy the data into a SharePoint table every 10 minutes. 

The app runs really well when using the data in SharePoint, but I havent found a suitable way to sync a SP table and SQL. 

I tried using flow - Every 10 mins  Get SQL Rows & create item in SP list.

Unfortunately flow cant seem to overwrite existing rows, so I need to do a apply to each/condition, which really slows it down. 

 

Any other suggestions? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Most efficient way to get data from on prem SQL to PowerAPP

I agree.. Using Collections fastens the app alot. try to run the execute SQL from MS flow and load it to the Collection using on start function... on update, you can patch both collection with the Sql table

View solution in original post

8 REPLIES 8
strategery
Level 8

Re: Most efficient way to get data from on prem SQL to PowerAPP

It really depends on your needs, but I found that PowerApps filters work much faster on collections, so I Collect the SQL records on initial startup. The rest of the app uses the collection. Anytime they add/modify records, I run a Refresh('SQL Datasource');ClearCollect(blah, 'SQL Datasource'). If I expect users to add/modify several records at a time then step away for a bit, I put an idle timer on the main page that refreshes when idle for a time rather than after each save, that way the refresh doesn't slow them down, but when they come back they have current data.

 

Gains can be made on the SQL side possibly. Add indexes for fields that get searched. Pre-filter the data using a view if you possibly can (i.e. If you don't need last week/month/year records, filter them out), then rather than connecting to your table, connect to that view. I always connect to a view, that way I can control what PowerApps and Power BI are getting on the fly.

Anonymous
Not applicable

Re: Most efficient way to get data from on prem SQL to PowerAPP

I agree.. Using Collections fastens the app alot. try to run the execute SQL from MS flow and load it to the Collection using on start function... on update, you can patch both collection with the Sql table

View solution in original post

nick9one1
Level: Powered On

Re: Most efficient way to get data from on prem SQL to PowerAPP

Is there a limit to the number of items you can populate an on start collection with?

The table has about 3000 rows.

 

The ideal solution would be to have a collection external to the app so that the user dosnt have to wait for it to populate.

 

I've created a dataset in PowerBI but it doesnt look like it is accessible through PowerApps

Mike8
Level 10

Re: Most efficient way to get data from on prem SQL to PowerAPP

Hello,

If you do what Partha says, you can have the 3000 records from Flow in less than a second.

strategery
Level 8

Re: Most efficient way to get data from on prem SQL to PowerAPP

Can someone elaborate on that? I'm not exactly sure what Partha is saying, and I may learn something new here

Mike8
Level 10

Re: Most efficient way to get data from on prem SQL to PowerAPP

The following link can help you get the idea:
https://powerapps.microsoft.com/nl-nl/blog/return-an-array-from-flow-to-powerapps-response-method/

You can also check at the bottom of the homepage the two screen animations:
www.metamicro.nlCapture.PNG

Community Support Team
Community Support Team

Re: Most efficient way to get data from on prem SQL to PowerAPP

HI @nick9one1,

There are many reasons that an app can be slow to load, slow to respond, and slow to write to data sources, please check and and see the following blog for more details:

https://baizini-it.com/blog/index.php/2017/09/13/powerapps-improving-app-performance/

I agree with @strategery's thought almost. You could consider take a try to save your SQL Table data into a Collection within your app using ClearCollect function when your app is started.

The user @AleChoski has made a test on the limit of the number of items you can populate on a Collection, please check and see the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Most-efficient-way-to-get-data-from-on-prem-S...

So the Collection could store 4000 records within an app at least. Actually, the limit of the number of items you can populate on a Collection is based on your computer's configuration (e.g. RAM). Currently, there is no online doc to introduce the limit of the number of items you can populate on a Collection within PowerApps.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dawidvh
Level 10

Re: Most efficient way to get data from on prem SQL to PowerAPP

Hi @nick9one1 

 

Below are two videos dealing with advanced queries to SQL from PowerApps (using Flow).
For SQL Azure you can use direct (native) queries:
https://youtu.be/DII10gK715I

 

For on-premesis SQL servers, native queries are not supported from Flow (you will get an error: operation Execute Native Sql is currently not supported using an on-prem gateway connection), so we have to use stored procedures to accomplish the same:
https://youtu.be/BAGBzI4zdww

 

Please let me know if you don't come right.

 

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 mark this as the answer to close the topic and make it easier to find for other people with similar questions.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,456)