<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Query Folding &#8211; DataMartIn</title>
	<atom:link href="https://datamartin.ca/tag/query-folding/feed/" rel="self" type="application/rss+xml" />
	<link>https://datamartin.ca</link>
	<description>We Know Data</description>
	<lastBuildDate>Tue, 30 Jul 2024 13:22:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
	<item>
		<title>Importance of Query folding and good practices</title>
		<link>https://datamartin.ca/2022/09/19/importance-of-query-folding-and-good-practices/</link>
		
		<dc:creator><![CDATA[Nuric Ugarte]]></dc:creator>
		<pubDate>Mon, 19 Sep 2022 23:17:07 +0000</pubDate>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[Data Modeling]]></category>
		<category><![CDATA[Query Folding]]></category>
		<guid isPermaLink="false">https://site1668528124.mywhc.ca/?p=413</guid>

					<description><![CDATA[Query Folding is the capability of Power Query to delegate some of the transformations to the source to improve performance. In this post you will see its importance and good practices guide to achieve it. According to official documentation the following data sources support query folding: &#8211; Relational databases (SQL Server, Oracle, etc.). -OData sources (including [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Query Folding is the capability of </strong>Power Query to delegate some of the transformations to the source to improve performance. In this post you will see its importance and good practices guide to achieve it.</p>
<p>According to official <a href="https://docs.microsoft.com/en-us/power-query/power-query-folding#transformations-that-can-achieve-folding" data-anchor="#transformations-that-can-achieve-folding">documentation</a> the following data sources support query folding:</p>
<p>&#8211; Relational databases (SQL Server, Oracle, etc.).</p>
<p>-OData sources (including SharePoint lists).</p>
<p>&#8211; Active Directory.</p>
<p>Data sources like flat files (Excel, CSV, txt, etc.), blobs, and web usually do not support it. Check <a href="https://docs.microsoft.com/en-us/power-query/power-query-folding#transformations-that-prevent-folding" data-anchor="#transformations-that-prevent-folding">here</a> the list of transformations that prevent query folding.</p>
<p>You can check if the query folding occurs by right-clicking on the last applied steps and validating if View Native Query option is enabled, when the View Native Query option is grayed out, it means that this specific step or transformation is executed with local resources.</p>
<p><strong><img decoding="async" class=" wp-image-586 aligncenter" src="https://datamartin.ca/wp-content/uploads/2022/09/native-query-160x300.jpg" alt="" width="206" height="386" srcset="https://datamartin.ca/wp-content/uploads/2022/09/native-query-160x300.jpg 160w, https://datamartin.ca/wp-content/uploads/2022/09/native-query.jpg 387w" sizes="(max-width: 206px) 100vw, 206px" /></strong></p>
<p><strong>Query Folding importance:</strong></p>
<p><strong>&#8211; Tables in import mode</strong> <a id="QueryFolding"></a>will have a lower resource utilization and faster refresh time.</p>
<p><strong>&#8211; Direct Query and Dual storage mode</strong> table only admit Power Query queries that can be folded.</p>
<p>&#8211; To be able to configure the <strong><u>incremental refresh</u> </strong>in a table, it is essential that the query folding can be achieved.</p>
<p><strong>Query folding good practices:</strong></p>
<p><strong>&#8211; Fully Folding:</strong> The preferred scenario is to achieve a query folding fully, that is the source executes all required transformations and returns to Power BI the desired result set.</p>
<p><strong><img decoding="async" class="wp-image-627 aligncenter" src="https://datamartin.ca/wp-content/uploads/2022/09/post-image-2-300x108.jpg" alt="" width="436" height="157" srcset="https://datamartin.ca/wp-content/uploads/2022/09/post-image-2-300x108.jpg 300w, https://datamartin.ca/wp-content/uploads/2022/09/post-image-2.jpg 736w" sizes="(max-width: 436px) 100vw, 436px" /></strong><strong>&#8211; Partial Folding:</strong> Place <a href="https://docs.microsoft.com/en-us/power-query/power-query-folding#transformations-that-can-achieve-folding"><u>steps that support query folding</u></a> at the beginning and move the <a href="https://docs.microsoft.com/en-us/power-query/power-query-folding#transformations-that-prevent-folding"><u>steps that prevent query folding</u></a> later because these transformations will be loaded into the local cache and processed locally by Power BI engine.</p>
<p>The idea is to maximize the performance getting as much query folding as possible. However, the recommendation is to avoid this option whenever you can.</p>
<ul>
<li><strong>Native Query:</strong> If you use a native query include all the logic of the required transformations there, because any other transformations applied to the results of this function will be processed with local resources.</li>
<li><strong>Apply the transformations in the data source:</strong> When you identify that your query requires a large number of steps that can’t be folded, apply the transformations in the data source <u>using a database view or by physically preparing and materializing data. </u></li>
</ul>
<p>I recommend you create a view because it can provide you with multiple advantages over regular tables. Check this interesting <a href="https://data-mozart.com/3-reasons-to-use-views-instead-of-tables-in-power-bi/">article</a> about that.</p>
<p><strong>Conclusion</strong></p>
<p>When you are working with a relational data source (such as SQL Server) always check the query folding. If most of the steps do not support it, use another approach for the transformations.</p>
<p>Not applying these recommendations in your data model could exponentially increase resource usage and refresh time and will prevent you from using Direct query or Dual storage mode and apply incremental refresh policies in your data model.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
