Power BI 最佳化指南Optimization guide for Power BI

此文章提供的指導方針可讓開發人員與系統管理員建立並維護最佳化的 Power BI 解決方案。This article provides guidance that enables developers and administrators to produce and maintain optimized Power BI solutions. 您可以在不同的架構層級最佳化您的解決方案。You can optimize your solution at different architectural layers. 這些層級包括:Layers include:

  • 資料來源The data source(s)
  • 資料模型The data model
  • 視覺效果,包括儀表板、Power BI 報表,以及 Power BI 編頁報表Visualizations, including dashboards, Power BI reports, and Power BI paginated reports
  • 環境,包括容量、資料閘道與網路The environment, including capacities, data gateways, and the network

最佳化資料模型Optimizing the data model

資料模型支援整個視覺效果體驗。The data model supports the entire visualization experience. 資料模型可能是外部裝載或內部裝載,而在 Power BI 中其稱為「資料集」 。Data models are either external-hosted or internal-hosted, and in Power BI they are referred to as datasets. 請務必了解您的選項,並為您的解決方案選擇適當的資料集類型。It's important to understand your options, and to choose the appropriate dataset type for your solution. 資料集模式有三種:匯入、DirectQuery 及複合。There are three dataset modes: Import, DirectQuery, and Composite. 如需詳細資訊,請參閱 Power BI 服務中的資料集以及 Power BI 服務中的資料集模式For more information, see Datasets in the Power BI service, and Dataset modes in the Power BI service.

如需特定的資料集模式指導方針,請參閱:For specific dataset mode guidance, see:

最佳化視覺效果Optimizing visualizations

Power BI 視覺效果可以是儀表板、Power BI 報表,或 Power BI 編頁報表。Power BI visualizations can be dashboards, Power BI reports, or Power BI paginated reports. 每個都有不同的架構,因此每個都有自己的指導方針。Each has different architectures, and so each has their own guidance.


請務必了解,Power BI 會維護儀表板圖格的快取,但動態報表圖格與串流圖格除外。It's important to understand that Power BI maintains a cache for your dashboard tiles—except live report tiles, and streaming tiles. 如需詳細資訊,請參閱 Power BI 中的資料重新整理 (圖格重新整理)For more information, see Data refresh in Power BI (Tile refresh). 如果您的資料集強制執行動態資料列層級安全性 (RLS),請務必了解效能方面的影響,因為圖格會以每個使用者為基礎進行快取。If your dataset enforces dynamic row-level security (RLS), be sure to understand performance implications as tiles will cache on a per-user basis.

當您將動態報表圖格釘選到儀表板時,其內容不是由查詢快取提供。When you pin live report tiles to a dashboard, they're not served from the query cache. 相反地,其行為就像報表一樣,而且會即時對後端核心進行查詢。Instead, they behave like reports, and make queries to back-end cores on the fly.

正如其名,從快取中擷取資料所提供的效能,會比依賴資料來源更佳且更一致。As the name suggests, retrieving the data from the cache provides better and more consistent performance than relying on the data source. 利用這項功能的其中一種方式是讓儀表板成為您使用者的第一個登陸頁面。One way to take advantage of this functionality is to have dashboards be the first landing page for your users. 將常用和經常要求的視覺效果釘選到儀表板。Pin often-used and highly requested visuals to the dashboards. 如此一來,儀表板會成為重要的「第一線防護」,這可以提供容量負載較低的一致效能。In this way, dashboards become a valuable "first line of defense", which delivers consistent performance with less load on the capacity. 使用者仍然可以按一下報表,以分析詳細資料。Users can still click through to a report to analyze details.

針對 DirectQuery 與即時連線資料集,系統會透過定期查詢資料來源來更新快取。For DirectQuery and live connection datasets, the cache is updated on a periodic basis by querying the data source. 根據預設,每小時會更新一次快取,不過您可以在資料集設定中設定不同的頻率。By default, it happens every hour, though you can configure a different frequency in the dataset settings. 每個快取更新都會將查詢傳送至底層資料來源,以更新快取。Each cache update will send queries to the underlying data source to update the cache. 產生的查詢數目取決於釘選到依賴該資料來源儀表板的視覺效果數。The number of queries that generate depends on the number of visuals pinned to dashboards that rely on the data source. 請注意,如果啟用資料列層級安全性,則會為每個不同的安全性內容產生查詢。Notice that if row-level security is enabled, queries are generated for each different security context. 例如,假設對使用者進行分類的角色有兩種,而其對資料有兩種不同檢視。For example, consider there are two different roles that categorize your users, and they have two different views of the data. 在查詢快取重新整理期間,Power BI 會產生兩組查詢。During query cache refresh, Power BI generates two sets of queries.

Power BI 報表Power BI reports

針對最佳化 Power BI 報表設計,有一些建議。There are several recommendations for optimizing Power BI report designs.


當報表是以 DirectQuery 資料集為基礎時,如需額外的報表設計最佳化,請參閱 Power BI Desktop 中的 DirectQuery 模型指導方針 (最佳化報表設計)When reports are based on a DirectQuery dataset, for additional report design optimizations, see DirectQuery model guidance in Power BI Desktop (Optimize report designs).

套用限制最嚴格的篩選條件Apply the most restrictive filters

視覺效果所需顯示的資料越多,要載入的視覺效果就越慢。The more data that a visual needs to display, the slower that visual is to load. 雖然此原則看起來很明顯,但卻很容易忘記。While this principle seems obvious, it's easy to forget. 例如:假設您有大型資料集。For example: suppose you have a large dataset. 除了該資料集外,您還使用了資料表來建置報表。Atop of that dataset, you build a report with a table. 終端使用者會在頁面上使用交叉分析篩選器來取得想要的資料列,且通常只會對數十個資料列感興趣。End users use slicers on the page to get to the rows they want—typically, they're only interested in a few dozen rows.

一個常見錯誤是在不篩選的情況下保留資料表預設檢視,亦即全部超過 1 億個資料列。A common mistake is to leave the default view of the table unfiltered—that is, all 100M+ rows. 在每次重新整理時,都會將這些資料列的資料載入記憶體,並進行解壓縮。The data for these rows loads into memory and is uncompressed at every refresh. 這種處理會造成龐大的記憶體需求。This processing creates huge demands for memory. 解決方式:使用「前 N 筆」篩選條件來減少資料表顯示的最大項目數。The solution: use the "Top N" filter to reduce the max number of items that the table displays. 您可以將最大項目設為超過使用者需要的數量,例如 10,000 筆。You can set the max item to larger than what users would need, for example, 10,000. 結果是不但終端使用者的體驗不會變更,記憶體的用量還會大幅下降。The result is the end-user experience doesn't change, but memory use drops greatly. 而最重要的是,效能也會改善。And most importantly, performance improves.

建議您將如上設計方法用於報表中的每一個視覺效果。A similar design approach to the above is suggested for every visual in your report. 問問自己,需要這個視覺效果中的所有資料嗎?Ask yourself, is all the data in this visual needed? 是否有任何方式可以進一步篩選視覺效果中顯示的資料量,並將對終端使用者體驗的影響降至最低?Are there ways to filter the amount of data shown in the visual with minimal impact to the end-user experience? 請記住,資料表特別耗費資源。Remember, tables in particular can be expensive.

限制報表頁面上的視覺效果Limit visuals on report pages

上述原則同樣適用於新增至報表頁面的視覺效果數目。The above principle applies equally to the number of visuals added to a report page. 強烈建議您限制特定報表頁面上只顯示必要的視覺效果數目。It's highly recommended you limit the number of visuals on a particular report page to only what is necessary. 鑽研頁面報表頁面工具提示十分適合提供其他詳細資料,而不會將更多視覺效果塞滿報表。Drillthrough pages and report page tooltips are great ways to provide additional details without jamming more visuals onto the page.

評估自訂視覺效果效能Evaluate custom visual performance

請務必以其步調放入每個自訂視覺效果,以確保高效能。Be sure to put each custom visual through its paces to ensure high performance. 最佳化不佳的 Power BI 視覺效果可能會對整個報表效能造成負面影響。Poorly optimized Power BI visuals can negatively affect the performance of the entire report.

Power BI 編頁報表Power BI paginated reports

Power BI 編頁報表設計可以透過將最佳做法設計套用至報表的資料擷取來進行最佳化。Power BI paginated report designs can be optimized by applying best practice design to the report's data retrieval. 如需詳細資訊,請參閱編頁報表的資料擷取指導方針For more information, see Data retrieval guidance for paginated reports.

此外,請確定您的容量有足夠的記憶體配置給編頁報表工作負載Also, ensure your capacity has sufficient memory allocated to the paginated reports workload.

將環境最佳化Optimizing the environment

您可以透過設定容量設定、調整資料閘道大小,以及降低網路延遲,將 Power BI 環境最佳化。You can optimize the Power BI environment by configuring capacity settings, sizing data gateways, and reducing network latency.

容量設定Capacity settings

使用 Power BI Premium (P SKU) 或 Power BI Embedded (A SKU,A4-A6) 提供的容量時,您可管理容量設定。When using capacities—available with Power BI Premium (P SKUs), or Power BI Embedded (A SKUs, A4-A6)—you can manage capacity settings. 如需詳細資訊,請參閱管理 Premium 容量For more information, see Managing Premium capacities. 如需如何最佳化容量的指導方針,請參閱最佳化 Premium 容量For guidance on how to optimize your capacity, see Optimizing Premium capacities.

閘道大小調整Gateway sizing

每當 Power BI 必須存取無法直接透過網際網路存取的資料時,就需要閘道。A gateway is required whenever Power BI must access data that isn't accessible directly over the Internet. 您可以在內部部署伺服器或 VM 裝載的基礎結構即服務 (IaaS) 上安裝內部部署資料閘道You can install the on-premises data gateway on a server on-premises, or VM-hosted Infrastructure-as-a-Service (IaaS).

若要了解閘道工作負載與大小調整建議,請參閱內部部署的資料閘道大小調整To understand gateway workloads and sizing recommendations, see On-premises data gateway sizing.

網路延遲Network latency

網路延遲可能會因要求到達 Power BI 服務所需時間增加以及傳遞回應所需時間增加而影響報表效能。Network latency can impact report performance by increasing the time required for requests to reach the Power BI service, and for responses to be delivered. Power BI 中的租用戶會指派給特定區域。Tenants in Power BI are assigned to a specific region.


若要判斷租用戶的所在位置,請參閱我的 Power BI 租用戶位於何處?To determine where your tenant is located, see Where is my Power BI tenant located?

租用戶中的使用者存取 Power BI 服務時,他們的要求一律會路由至此區域。When users from a tenant access the Power BI service, their requests always route to this region. 例如,當要求到達 Power BI 服務之後,服務可能會將其他要求傳送至底層資料來源或資料閘道,而這些要求也受限於網路延遲。As requests reach the Power BI service, the service may then send additional requests—for example, to the underlying data source, or a data gateway—which are also subject to network latency.

Azure Speed Test 這類工具可以指出用戶端與 Azure 區域之間的網路延遲。Tools such as Azure Speed Test provide an indication of network latency between the client and the Azure region. 一般而言,若要將網路延遲的影響降到最低,請盡量將資料來源、閘道和 Power BI 叢集保留在最接近的位置。In general, to minimize the impact of network latency, strive to keep data sources, gateways, and your Power BI cluster as close as possible. 要求最好位於相同區域內。Preferably, they reside within the same region. 如果網路延遲是問題,則您可以透過將其放置在雲端裝載的虛擬機器中,嘗試將閘道與資料來源放置在更接近 Power BI 叢集的位置。If network latency is an issue, try locating gateways and data sources closer to your Power BI cluster by placing them inside cloud-hosted virtual machines.

監視效能Monitoring performance

您可以監視效能以找出瓶頸。You can monitor performance to identify bottlenecks. 為了達到持續最佳化,建議您將焦點放在緩慢的查詢或報表視覺效果上。Slow queries—or report visuals—should be a focal point of continued optimization. 監視可以在 Power BI Desktop 中的設計階段,或 Power BI Premium 容量中的生產工作負載上完成。Monitoring can be done at design time in Power BI Desktop, or on production workloads in Power BI Premium capacities. 如需詳細資訊,請參閱在 Power BI 中監視報表效能For more information, see Monitoring report performance in Power BI.

後續步驟Next steps

如需本文的詳細資訊,請參閱下列資源︰For more information about this article, check out the following resources: