Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
smpa01
Super User
Super User

TSQL Query runs longer in Dataflow than in SSMS

Is there a reason why a TSQL query takes a lot longer (>15min) to run in DF than the same query in SSMS (~3min). The TSQL query is complex, consists of 4 large tables, table variable, scalar values, PATINDEX, INNER JOIN, LEFT JOIN, CROSS JOIN, CTE etc. With all these, SSMS gives the output in 3 min max. However, the same query runs in DF for more than 15 min and errors out.

 

Does nayone know why it happens? I was under the impression that PQWRY gives the output at the same amount of time as SSMS would do.

@ImkeF 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION

Hi @smpa01 

if "not part of SYSADMIN", perhaps you can contact the database administrator to trace on the sql server.

 

FYI:

Why Is Power BI Running My SQL Query Twice?
https://blog.crossjoin.co.uk/2020/07/05/why-is-power-bi-running-my-sql-query-twice/


Why Does Power BI Query My Data Source More Than Once?
https://blog.crossjoin.co.uk/2019/10/13/why-does-power-bi-query-my-data-source-more-than-once/


Finding Power Query Query Execution Times In Power BI And Excel Using SQL Server Profiler
https://blog.crossjoin.co.uk/2019/02/09/power-query-execution-times-using-sql-server-profiler/

 

Hope it helps!

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution✔️ to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
jeffshieldsdev
Solution Sage
Solution Sage

Can you check the SQL Profiler tool? My experience has been the native SQL queries will execute up to 3 times concurrently when coming from dataflows through a gateway.

 

EDIT: maybe there isn't a gateway, is it on-prem SQL Server or Azure?

@jeffshieldsdev 

maybe there isn't a gateway, is it on-prem SQL Server or Azure? there is a gateway, On-prem SQL Server

Can you check the SQL Profiler tool? - are you suggesting that I can connect the DF to SQL Server Profiler. Is it possible? If yes, which events to choose?

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Sorry, I could have been clearer.  I was suggesting refreshing your dataflow and checking SQL Profiler to see how many times the SQL is executing--it may be actually executing 3 times concurrently, causing the slower performance.

@jeffshieldsdev  thanks for clarification. Cant run trace on this sql server, not part of SYSADMIN. Thanks for your suggestion.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01 

if "not part of SYSADMIN", perhaps you can contact the database administrator to trace on the sql server.

 

FYI:

Why Is Power BI Running My SQL Query Twice?
https://blog.crossjoin.co.uk/2020/07/05/why-is-power-bi-running-my-sql-query-twice/


Why Does Power BI Query My Data Source More Than Once?
https://blog.crossjoin.co.uk/2019/10/13/why-does-power-bi-query-my-data-source-more-than-once/


Finding Power Query Query Execution Times In Power BI And Excel Using SQL Server Profiler
https://blog.crossjoin.co.uk/2019/02/09/power-query-execution-times-using-sql-server-profiler/

 

Hope it helps!

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution✔️ to help the other members find it more quickly.

GilbertQ
Super User
Super User

Hi @smpa01 

 

I would suggest making sure that your gateway is as close as to the SQL Server is possible. Could it be that the gateway is the bottleneck?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

@GilbertQmaking sure that your gateway is as close as to the SQL Server is possible - Sorry can you please elaboarte on that. I did not undertsanf what you meant by that.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.