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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
SachaG
Regular Visitor

PostgreSQL refresh errors in Power BI report

Hi there,

 

I have a report connected to an externally managed PostgreSQL database that was refreshing fine until the 4th October where it gave the error:

"DataSource.Error: PostgreSQL: 58000: ErrorCode: 08P01 sessionId: f22e9de6-648f-4476-9692-f131cb15c08e queryId: 936e542d-530f-4641-a944-3494320d6f2c Unknown error encountered. Reason: [com.facebook.presto.sql.tree.Union cannot be cast to com.facebook.presto.sql.tree.QuerySpecification]. DataSourceKind = PostgreSQL. DataSourcePath = [datasourcename] Message = 58000: ErrorCode: 08P01 sessionId: f22e9de6-648f-4476-9692-f131cb15c08e queryId: 936e542d-530f-4641-a944-3494320d6f2c Unknown error encountered. Reason: [com.facebook.presto.sql.tree.Union cannot be cast to com.facebook.presto.sql.tree.QuerySpecification]. ErrorCode = -2147467259. . The exception was raised by the IDbCommand interface. Table: Appended Opt-in."

 

I have since been on a wild goose chase trying to get this sorted. On inspecting the report I began to get another error: "PostgreSQL: 53300: Exceeded session limit of 10" so I assumed the issue was coming from the database side.

After contacting the database administrator, they have come back and told me the issue is with the session limit on the Power BI side, but I have tried adjusting the parallel loading simultaneous evaluations, and clearing the cache and all manner of other suggestions I have found online and nothing has worked.

On further investigation, the issue seems to be coming from a table where I am trying to append data together. If I remove this and load each appended table individually, it appears to be fine, but once I add the appended query I will receive one of the two above errors without fail. I also tried changing the query to a UNION ALL postgreSQL query instead of appending with Power Query but this didn't help either. I'm at a loss for where to go next and am exceedingly frustrated as it was working fine until one day it wasn't.

Any help would be greatly appreciated.

3 REPLIES 3
ReportGuru
Post Patron
Post Patron

Hi @SachaG it seems you’re dealing with two related challenges: PostgreSQL session limits and query errors in Power BI. Let’s break this down into actionable steps to address both issues:

1. Fixing PostgreSQL Session Limits

The error "53300: Exceeded session limit of 10" means PostgreSQL is running out of available sessions. Power BI may be opening too many concurrent connections during the data refresh process. Here’s how you can manage this:

Adjust Parallel Loading in Power BI:

  • Go to File > Options and Settings > Options.
  • Under Data Load, disable Enable parallel loading of tables and set the number of simultaneous evaluations to 1 or 2.

Optimize Queries:

If your queries involve large datasets or complex transformations, they might be overloading the system. To optimize:

  • Reduce the number of queries sent to the database.
  • Ensure transformations in Power Query are “foldable,” so computations happen in PostgreSQL instead of Power BI.

Increase PostgreSQL Session Limits (If Possible):

Work with your database administrator to review and adjust the session limit configuration on PostgreSQL. Temporarily increasing this limit can help identify if the problem stems from Power BI’s connections or the database itself.

2. Resolving "Union" Casting Errors

The com.facebook.presto.sql.tree.Union error indicates issues with how Power BI processes query logic when appending tables.

Using Native SQL Queries (UNION ALL):

You mentioned trying UNION ALL directly in PostgreSQL. Double-check the query format to ensure compatibility with PostgreSQL. Test it in a tool like pgAdmin.

Example:

 

SELECT * FROM table1 UNION ALL SELECT * FROM table2;
 

If this query works in PostgreSQL, replace Power Query's append operation with a native SQL query using this structure.

Simplify Power Query Logic:

If appending tables within Power Query is necessary:

  • Break the append operation into smaller, incremental steps.
  • Load and validate intermediate results to pinpoint where the issue arises.
  • Verify that column names and data types are consistent across all tables.

3. Monitoring and Debugging the Refresh Process

Power BI has built-in tools to analyze refresh issues:

  • Go to View > Performance Analyzer in Power BI Desktop.
  • Start a refresh and monitor the queries sent to PostgreSQL.

This can help you identify whether the bottleneck lies with the append operation, session limits, or another source.

4. Exploring Alternative Solutions

If these steps don’t resolve your issue, consider using a third-party tool like Windsor.ai. It provides seamless PostgreSQL integration and can simplify how data flows into Power BI.

Benefits of Windsor.ai:

  • Efficiently manages sessions and queries to reduce database load.
  • Allows direct integration with Power BI, bypassing some Power Query limitations.
  • Handles large datasets and complex transformations more effectively.

Hope these suggestions help! 

v-xuxinyi-msft
Community Support
Community Support

Hi @SachaG 

 

Was rajendraongole1 's reply helpful? If so, could you please mark it as a solution? This will help more users facing the same or similar difficulties. Thanks!

 

Please feel free to let me know if there are still problems.

 

Best Regards,
Yulia Xu

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Users online (1,847)