
Sun Sep 15 10:43:12 UTC 2024: ## Power BI Users Can Now See the Exact SQL Generated for DirectQuery Models
**Seattle, WA – [Date]** – Microsoft Fabric expert Chris Webb has discovered a new method for Power BI users to view the exact SQL queries generated by DirectQuery models, even without access to the source database. This is especially useful for performance tuning, as users can now identify bottlenecks and optimize queries for better performance.
Previously, viewing the SQL generated by DirectQuery models was difficult, requiring specific permissions and access to the source database. However, Webb has found a way to utilize SQL Server Profiler and the “M Data Provider Events/Execute Source Query” event to capture the actual SQL sent to the source database. This method currently works with M-based connectors like Snowflake.
The key is to connect Profiler to Power BI Desktop and monitor the events. For example, when a simple SUM measure is added to a Power BI report, Profiler shows two events: a DirectQuery Begin/End event pair and an “Execute Source Query” event. The former shows the TSQL emitted by Power BI, while the latter reveals the actual SQL sent to the source database, in this case, Snowflake.
This discovery will be a boon to Power BI users who rely on DirectQuery models and want to understand how their queries are translated and executed. It empowers users to identify areas for improvement and fine-tune their queries for optimal performance.
**This method is currently limited to Power BI Desktop and only applicable to M-based connectors.** However, Webb suggests that this discovery may lead to further developments and wider application in the future.