Forum Discussion
Direct query queries against one (1) specific view in Snowflake queries the entire model instead
Hi KrisD ,
When you use DirectQuery, you should always consider performance, primarily to ensure that the back-end source has sufficient resources to provide a good experience for users. A good experience means that the visuals refresh in five seconds or less. For more performance advice, see About using DirectQuery in Power BI.
Using composite models adds additional performance considerations. A single visual can result in sending queries to multiple sources, which often pass the results from one query across to a second source. This situation can result in the following forms of execution:
-
A source query that includes a large number of literal values: For example, a visual that requests total Sales Amount for a set of selected Product Managers would first need to find which Products were managed by those product managers. This sequence must happen before the visual sends an SQL query that includes all of the product IDs in a
WHEREclause. -
A source query that queries at a lower level of granularity, with the data later being aggregated locally: As the number of Products that meet the filter criteria on Product Manager grows large, it can become inefficient or unfeasible to include all products in a
WHEREclause. Instead, you can query the relational source at the lower level of Products and then aggregate the results locally. If the cardinality of Products exceeds a limit of 1 million, the query fails. -
Multiple source queries, one per group by value: When the aggregation uses DistinctCount and is grouped by a column from another source, and if the external source doesn't support efficient passing of many literal values that define the grouping, it's necessary to send one SQL query per group by value.
A visual that requests a distinct count of CustomerAccountNumber from the SQL Server table by Product Managers imported from the spreadsheet would need to pass in the details from the Product Managers table in the query that's sent to SQL Server. Over other sources, Redshift, for example, this action is unfeasible. Instead, there would be one SQL query sent per Sales Manager, up to some practical limit, at which point the query would fail.
Each of these cases has its own implications on performance, and the exact details vary for each data source. Although the cardinality of the columns used in the relationship that joins the two sources remains low, a few thousand, performance shouldn't be affected. As this cardinality grows, you should pay more attention to the impact on the resulting performance.
Additionally, the use of many-to-many relationships means that separate queries must be sent to the underlying source for each total or subtotal level, rather than aggregating the detailed values locally. A simple table visual with totals would send two source queries, rather than one.
For more details, please refer to:
Use composite models in Power BI Desktop - Power BI | Microsoft Learn
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi and thanks for your reply.
However I can't find the answer to my question in the info you provided.
If I am not misinterpreting the text, it does not say why the query needs to join together every table in the model in my particular scenario. The 2 imported fact views are identical to the DQ fact views so there would be no need to query other tables. The dimensions are not referenced at all either in the dax or table visual or in any filters applied in the report itself. The values that are referenced in the dax like for instance '[Fact] CYCLE WAGON MAX 7 DAYS'[WAGON_TYPE] = "Wagon" also exist in the DIM tables, but why would the engine fetch values from there when the value is available in the view CYCLE WAGON MAX 7 DAYS'?
What also confuses me is how all these joins are performed when I have no active relationships between the DQ views and the rest of the model.