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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
TaariqMegaC
New Member

stack depth limit exceeded

Hi, I have data that is in a dataflow in powerBI that is brought in through PostgreSQL,

 

1 of the tables is currently not refreshing and giving the below error, please advise on what could be the common causes and what to look out for

 

We encountered the following error while fetching additional rows: "PostgreSQL: 54001: stack depth limit exceeded"

5 REPLIES 5
PijushRoy
Super User
Super User

Hi @TaariqMegaC 

 

PostgreSQL has a configuration parameter called max_stack_depth, which specifies the maximum safe depth of the server's execution stack. The default value is set to 2MB. If your queries are complex, they may exceed this limit, especially if they involve deep recursion or nested subqueries.

 

If your dataflow includes complex queries, particularly those involving nested updates or deep recursion, this could lead to the stack depth error. A contrived query can cause unreasonable amounts of time spent trying to flatten subqueries, which may not only lead to performance issues but also trigger the stack depth limit.

 

As a potential workaround, you can increase the max_stack_depth parameter within a session if you have superuser access. This adjustment may temporarily resolve the issue but should be done cautiously, ensuring that it does not adversely affect the overall performance of the database.
SET max_stack_depth = '4MB'; -- Example value, adjust as needed

 

Consider whether any recent changes to the database schema or query design have introduced complexity. This could include new joins, additional calculated fields, or modifications in how data is being retrieved.

 

Performance-related issues, such as high load on the database server or resource throttling, can also contribute to this error. Monitoring the performance metrics can provide insights into whether resource limits are being exceeded.

 

If the error began occurring after a specific date, such as October 4th in your case, it may be worthwhile to investigate any changes made around that time, including updates to PostgreSQL itself or any changes in the data sources being queried

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Thank you please advise on the steps to increase it

Hi  @TaariqMegaC 
Thanks for reaching out with your query!


To better assist you,for more in-depth troubleshooting and to get insights from other experts, I recommend posting your issue in the PostgreSQL: Contact

 

Regards,
Atheeq.

Thank you, how do i increase the max stack depth

Elena_Kalina
Solution Specialist
Solution Specialist

Hi @TaariqMegaC 

The "stack depth limit exceeded" issue in PostgreSQL typically happens when a query involves too much recursion or overly complex operations that exceed PostgreSQL's memory stack limits(max_stack_depth parameter (default is 2MB)).

A few things we can check:

  1. Recursive Logic – Does the table involve any recursive CTEs, circular references, or self-referencing joins?

  2. Query Folding – Some Power Query transformations might generate inefficient SQL. Could you share the query steps applied to this table?

  3. Data Model – Are there any loops in relationships between this table and others?

  4. PostgreSQL Views/Functions – If the table relies on a view or function, we should verify its logic.

A quick fix might be simplifying the query or breaking it into smaller steps. If you can share:

  • The table structure

  • Any custom SQL or M-code used

  • The transformations applied in Power Query

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.