Source query optimization
Trace the request before optimizing
DirectQuery translates model requests into queries against a supported source. A slow visual may wait for source execution, gateway transfer, model evaluation or rendering. Establish a fixed snapshot and capture evidence at each layer rather than assuming an index will solve every delay. In the lab, January North revenue is 180 cents in a deliberately tiny synthetic dataset.
Keep filters useful to the source
Use a supported connector and select DirectQuery at connection time. Prefer typed, source-prepared columns and foldable transformations. Power Query folding concerns transformation translation; it is not the final SQL emitted for every report visual. View Native Query, where available, inspects an applied step. Performance Analyzer captures visual DAX; approved source monitoring captures actual database requests. DirectQuery calculated columns and RLS expressions have function restrictions: inspect each function’s documentation and test the actual connector. Do not copy a measure into a calculated column and assume support. Native SQL for a DirectQuery table must meet connector requirements; the SQL Server guidance calls for a SELECT without a CTE or stored procedure.
Example 1 — half-open date filter
Use labs/directquery/source.sqlite read-only. The following is hand-written SQLite SQL, not Power BI generated SQL. All amounts are integer cents.
SELECT SUM(RevenueCents) FROM SalesWHERE SaleDate >= '2025-01-01' AND SaleDate < '2025-02-01' AND Region = 'North';Expected: 180. The exclusive upper boundary prevents February 1 from being counted in January. EXPLAIN QUERY PLAN for the supplied local index is included in the verifier. Contrast with substr(SaleDate,1,7) = '2025-01', which may prevent use of the date range part of an index. Plans depend on statistics, selectivity and engine; a search in SQLite does not prove a SQL Server seek.
Example 2 — separate query layers
Define Revenue Cents = SUM(Sales[RevenueCents]) in two models with the same frozen SQL Server fixture and permissions, one Import and one DirectQuery. Filter January and North; both predict 180. Select a region with no rows: predict BLANK, not zero. Capture Performance Analyzer DAX and database-side statements for the DirectQuery variant, count actual requests for a single scripted selection, and record visual duration separately. In this environment only the SQLite arithmetic and local plan are measured; native counts remain empty.
Source design and concurrency
Work with the database owner to inspect query plans and indexes on join/filter columns; statistics and physical design depend on the source. Materialize expensive row expressions upstream where appropriate. Validate non-null matching dimension keys before enabling Assume referential integrity; otherwise an inner join may silently remove rows. Increasing connections or visual refresh frequency can overload a shared source. Use agreed rate limits, test on isolated infrastructure, and do not change production indexes or clear shared caches. Record cache state, source identity, gateway path and time window.
Practice — design a diagnostic
Predict February North revenue and the result for an absent region. Explain which artifact would prove folding and which would prove actual visual SQL. Propose a read-only source-plan comparison without changing an index. Compare your results with the admin-only solution.
Sources consulted 2026-11-29: directquery-model-guidance, desktop-directquery-about, power-query-folding, desktop-use-directquery. Installed connector and native engine not tested.