<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why does running OPTIMIZE not always improve Delta table performance? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177911#M57418</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Adding further to the points above, I would approach this as &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Assess → Optimize → Validate&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, rather than running OPTIMIZE routinely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;1. Assess whether OPTIMIZE is needed&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Start with table metadata and previous maintenance history:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DESCRIBE DETAIL catalog.schema.my_table;
DESCRIBE HISTORY catalog.schema.my_table;&lt;/LI-CODE&gt;&lt;P&gt;Check numFiles, sizeInBytes, partitioning, clustering columns and previous OPTIMIZE metrics (numRemovedFiles, numAddedFiles, p50FileSize).&lt;/P&gt;&lt;P&gt;Average file size (sizeInBytes / numFiles) is a useful initial indicator, although it can hide file-size variations.&lt;/P&gt;&lt;P&gt;Another useful feature is &lt;STRONG&gt;Query Performance Insights&lt;/STRONG&gt;, available through Query History and Query Profile:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;DATA_FILE_SIZE – small-file problem.&lt;/LI&gt;&lt;LI&gt;COVERAGE_STATS_DELTA – missing or unusable data-skipping statistics.&lt;/LI&gt;&lt;LI&gt;COVERAGE_STATS_OPTIMIZER – insufficient optimizer statistics.&lt;/LI&gt;&lt;LI&gt;DATA_SKEW – uneven processing distribution.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;These insights help determine whether compaction is actually required.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;2. Distinguish data layout from query planning&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;An important distinction is that these two commands serve different purposes:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ANALYZE TABLE my_table COMPUTE DELTA STATISTICS;

ANALYZE TABLE my_table COMPUTE STATISTICS&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;The former updates file-level statistics for data skipping, while the latter collects statistics for the query optimizer. OPTIMIZE alone may not resolve inefficient join plans.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;3. Quantify the actual benefit&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Use Delta Time Travel to compare the same query against table versions immediately before and after the OPTIMIZE commit, under comparable compute and cache conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To measure file-pruning efficiency:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT
    statement_id,
    execution_duration_ms,
    ROUND(
        100.0 * pruned_files_bytes /
        NULLIF(pruned_files_bytes + read_files_bytes, 0),
        2
    ) AS pruning_pct,
    read_bytes,
    shuffle_read_bytes,
    spilled_local_bytes
FROM system.query.history
WHERE statement_id IN ('before_id', 'after_id')&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;If file count decreases but pruning efficiency and bytes read remain similar, compaction may have improved file-management overhead without significantly reducing scan volume.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If scan performance improves but overall execution time does not, investigate joins, shuffle, skew and spill.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ultimately, OPTIMIZE should be evaluated against workload performance and maintenance cost, not just the reduction in file count.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;References:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/user/queries/performance-insights" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Query Performance Insights&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-analyze-compute-statistics" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;ANALYZE TABLE&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/admin/system-tables/query-history#understanding-scan-metrics" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Understanding Query Scan Metrics&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Sat, 28 Nov 2026 10:49:03 GMT</pubDate>
    <dc:creator>data_pulse</dc:creator>
    <dc:date>2026-11-28T10:49:03Z</dc:date>
    <item>
      <title>Why does running OPTIMIZE not always improve Delta table performance?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177891#M57405</link>
      <description>&lt;P&gt;&lt;SPAN&gt;After running OPTIMIZE on a large Delta table, the number of files may reduce significantly, but the actual query execution time does not improve much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What could be the reason for this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How do we determine whether the performance issue is related to file sizes, poor data skipping, inefficient joins or the choice of clustering columns?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a recommended way to measure the actual benefit of running OPTIMIZE?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Nov 2026 09:15:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177891#M57405</guid>
      <dc:creator>dataumer</dc:creator>
      <dc:date>2026-11-28T09:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why does running OPTIMIZE not always improve Delta table performance?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177908#M57417</link>
      <description>&lt;DIV&gt;&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/274445"&gt;@dataumer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;OPTIMIZE on its own does bin-packing. It turns many small files into fewer, larger ones, which helps when the problem really was small files. It doesn't change how the data is spread across those files. If the values your queries filter on are scattered across every file, the query still has to read almost all of them, just in bigger pieces. Bin-packing is also idempotent, so running it again on the same data does nothing. On Unity Catalog managed tables with predictive optimization, OPTIMIZE may already be running on its own, so a manual run may not have much left to do.&lt;/P&gt;&lt;P&gt;What makes queries read fewer files is data skipping, and that depends on two things:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Statistics on the columns you filter by. By default they're collected only on the first 32 columns of the schema. You can change that with delta.dataSkippingStatsColumns. ANALYZE TABLE ... COMPUTE DELTA STATISTICS recomputes them for existing data.&lt;/LI&gt;&lt;LI&gt;A layout where each file covers a narrow range of those columns. That's what liquid clustering does. Pick up to four keys from the columns most used in filters, or use CLUSTER BY AUTO and let Databricks choose. If you change the keys later, regular OPTIMIZE only clusters what isn't clustered yet. Use OPTIMIZE FULL to recluster everything.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;To find where the time actually goes, open the query profile. The Top operators panel shows the slowest operators, and the filter icon on the scan shows what percentage of the data was pruned. If the scan dominates and pruning is low, it's a layout or statistics problem. If most of the time is in shuffle or join operators, OPTIMIZE won't change much, and the join strategy is where to look.&lt;/P&gt;&lt;P&gt;To measure the benefit, compare the same queries before and after in system.query.history:&lt;/P&gt;&lt;P&gt;SELECT start_time, total_duration_ms, read_files, pruned_files, read_bytes, shuffle_read_bytes, read_io_cache_percent, from_result_cache FROM system.query.history WHERE statement_text ILIKE '%my_table%' AND execution_status = 'FINISHED' AND start_time &amp;gt;= current_timestamp() - INTERVAL 14 DAYS ORDER BY start_time;&lt;/P&gt;&lt;P&gt;A real gain shows up as more pruned_files and less read_bytes, not just a lower duration. Check read_io_cache_percent and from_result_cache too, so a run served from cache doesn't look like an OPTIMIZE win. Note that statement_text is redacted unless you're an account admin or in the databricks_pii_access group.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/tables/operations/optimize" target="_self"&gt;OPTIMIZE&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/tables/data-skipping" target="_self"&gt;Data skipping&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/tables/clustering" target="_self"&gt;Liquid clustering&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/user/queries/query-profile" target="_self"&gt;Query profile&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/admin/system-tables/query-history" target="_self"&gt;Query history system table&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 28 Nov 2026 10:13:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177908#M57417</guid>
      <dc:creator>ThomazNeto</dc:creator>
      <dc:date>2026-11-28T10:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why does running OPTIMIZE not always improve Delta table performance?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177911#M57418</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Adding further to the points above, I would approach this as &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Assess → Optimize → Validate&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, rather than running OPTIMIZE routinely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;1. Assess whether OPTIMIZE is needed&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Start with table metadata and previous maintenance history:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DESCRIBE DETAIL catalog.schema.my_table;
DESCRIBE HISTORY catalog.schema.my_table;&lt;/LI-CODE&gt;&lt;P&gt;Check numFiles, sizeInBytes, partitioning, clustering columns and previous OPTIMIZE metrics (numRemovedFiles, numAddedFiles, p50FileSize).&lt;/P&gt;&lt;P&gt;Average file size (sizeInBytes / numFiles) is a useful initial indicator, although it can hide file-size variations.&lt;/P&gt;&lt;P&gt;Another useful feature is &lt;STRONG&gt;Query Performance Insights&lt;/STRONG&gt;, available through Query History and Query Profile:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;DATA_FILE_SIZE – small-file problem.&lt;/LI&gt;&lt;LI&gt;COVERAGE_STATS_DELTA – missing or unusable data-skipping statistics.&lt;/LI&gt;&lt;LI&gt;COVERAGE_STATS_OPTIMIZER – insufficient optimizer statistics.&lt;/LI&gt;&lt;LI&gt;DATA_SKEW – uneven processing distribution.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;These insights help determine whether compaction is actually required.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;2. Distinguish data layout from query planning&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;An important distinction is that these two commands serve different purposes:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ANALYZE TABLE my_table COMPUTE DELTA STATISTICS;

ANALYZE TABLE my_table COMPUTE STATISTICS&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;The former updates file-level statistics for data skipping, while the latter collects statistics for the query optimizer. OPTIMIZE alone may not resolve inefficient join plans.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;3. Quantify the actual benefit&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Use Delta Time Travel to compare the same query against table versions immediately before and after the OPTIMIZE commit, under comparable compute and cache conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To measure file-pruning efficiency:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT
    statement_id,
    execution_duration_ms,
    ROUND(
        100.0 * pruned_files_bytes /
        NULLIF(pruned_files_bytes + read_files_bytes, 0),
        2
    ) AS pruning_pct,
    read_bytes,
    shuffle_read_bytes,
    spilled_local_bytes
FROM system.query.history
WHERE statement_id IN ('before_id', 'after_id')&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;If file count decreases but pruning efficiency and bytes read remain similar, compaction may have improved file-management overhead without significantly reducing scan volume.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If scan performance improves but overall execution time does not, investigate joins, shuffle, skew and spill.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ultimately, OPTIMIZE should be evaluated against workload performance and maintenance cost, not just the reduction in file count.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;References:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/user/queries/performance-insights" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Query Performance Insights&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-analyze-compute-statistics" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;ANALYZE TABLE&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/admin/system-tables/query-history#understanding-scan-metrics" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Understanding Query Scan Metrics&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Sat, 28 Nov 2026 10:49:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/177911#M57418</guid>
      <dc:creator>data_pulse</dc:creator>
      <dc:date>2026-11-28T10:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why does running OPTIMIZE not always improve Delta table performance?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/178050#M57469</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/274445"&gt;@dataumer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;OPTIMIZE &lt;/STRONG&gt;by default only does bin-packing - it merges small files into evenly sized large files and the operation is idempotent and makes no changes to the data itself. So if your query is slow because it filters on a column and has to read every file anyway, compaction shrinks the file count but not the bytes scanned - each rewritten file still spans nearly the full min/max range of the filter column, so Delta's per-file statistics (min/max, null counts, record counts) cannot skip anything. &lt;STRONG&gt;Data skipping&lt;/STRONG&gt; only works when similar values are physically co-located and plain bin-packing does not reorder rows. Other reasons queries don't speed up after OPTIMIZE is that&amp;nbsp;the &lt;STRONG&gt;workload&lt;/STRONG&gt; is not &lt;STRONG&gt;filter driven&lt;/STRONG&gt; (full table aggregations were never file bound), &lt;STRONG&gt;stats&lt;/STRONG&gt; are &lt;STRONG&gt;not collected&lt;/STRONG&gt; for the column you filter on (only the first 32 schema columns get stats by default and string/timestamp stats are truncated) or the bottleneck is a join/&lt;STRONG&gt;shuffle/skew&lt;/STRONG&gt; visible in the Query Profile. You can check the &lt;STRONG&gt;query profile&lt;/STRONG&gt; of the slow query before and after OPTIMIZE and compare files read vs files pruned, bytes scanned and shuffle spill. If files pruned stays near zero, it's a data-skipping/clustering problem. The files are not issue&amp;nbsp;if the scan listing overhead dropped.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use &lt;STRONG&gt;liquid clustering&lt;/STRONG&gt;&amp;nbsp;which incrementally colocates data by the filter keys on every write and every OPTIMIZE, lets you change clustering keys later without a full rewrite, and works best on &lt;STRONG&gt;high-cardinality&lt;/STRONG&gt;, &lt;STRONG&gt;skewed&lt;/STRONG&gt;&amp;nbsp;or evolving filter columns. Run &lt;STRONG&gt;OPTIMIZE &lt;/STRONG&gt;(or use &lt;STRONG&gt;predictive optimization&amp;nbsp;&lt;/STRONG&gt;on &lt;STRONG&gt;UC managed tables&lt;/STRONG&gt;) so compaction and re clustering run on a schedule automatically. Check the optimization properly by running few queries before and after and comparing the profile metrics (files pruned and bytes read)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;-- Liquid clustering
CREATE TABLE catalog.schema.sales (
  sale_date TIMESTAMP, customer_id BIGINT, amount DECIMAL(10,2)
) CLUSTER BY customer_id;

OPTIMIZE catalog.schema.sales;

-- Old tables without liquid clustering - ZORDER
OPTIMIZE catalog.schema.sales ZORDER BY (customer_id);&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 29 Nov 2026 15:06:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/178050#M57469</guid>
      <dc:creator>balajij8</dc:creator>
      <dc:date>2026-11-29T15:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why does running OPTIMIZE not always improve Delta table performance?</title>
      <link>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/178100#M57479</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;OPTIMIZE primarily improves the physical layout of a Delta table by compacting small files. However, reducing the number of files does not necessarily reduce the amount of data processed by a query.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would investigate the following.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;1. Compare table metrics before and after OPTIMIZE&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;DESCRIBE DETAIL catalog.schema.orders;

DESCRIBE HISTORY catalog.schema.orders LIMIT 5;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Compare the number of files, total table size and OPTIMIZE operation metrics.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If the file count decreases significantly but the query still scans approximately the same amount of data, file fragmentation may not be the primary bottleneck.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;2. Review data skipping and clustering&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, if a table contains 500 million records and most queries filter by &lt;/SPAN&gt;&lt;SPAN&gt;customer_id&lt;/SPAN&gt;&lt;SPAN&gt;, simply compacting files may not improve performance significantly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For a suitable Liquid Clustering table, consider:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;ALTER TABLE catalog.schema.orders
CLUSTER BY (customer_id);

OPTIMIZE catalog.schema.orders;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Clustering can improve data skipping by organizing similar values into fewer files. Choose clustering columns based on frequently used query filters.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;3. Inspect the query profile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Compare these metrics before and after optimization:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Number of files and bytes scanned.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Percentage of data pruned.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Scan duration.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Shuffle read and write size.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Disk spill and join execution time.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;If joins and aggregations consume most of the execution time, file compaction alone will provide limited improvement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;4. Measure performance under consistent conditions&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Run the same query multiple times before and after OPTIMIZE using identical compute configurations and comparable cache conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For SQL warehouses, disable the result cache during benchmarking:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;SET use_cached_result = false;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Compare execution time, bytes scanned and files pruned. Also verify that statistics are available for the frequently filtered columns.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My recommendation is to identify whether the bottleneck is related to scanning data or processing data before repeatedly running OPTIMIZE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;OPTIMIZE improves file layout, but it cannot resolve inefficient joins, data skew or expensive aggregations. The clustering example above assumes a compatible table and runtime.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Official references:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Optimize data file layout&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Liquid Clustering&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Query performance insights&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Performance optimization best practices&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 29 Nov 2026 19:27:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-does-running-optimize-not-always-improve-delta-table/m-p/178100#M57479</guid>
      <dc:creator>tajamulkhan</dc:creator>
      <dc:date>2026-11-29T19:27:16Z</dc:date>
    </item>
  </channel>
</rss>

