cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Auto optimize config

Anonymous
Not applicable

Does auto-optimize work for existing tables only or will it work for both existing and new tables when we enable at the cluster config level?

1 ACCEPTED SOLUTION

Accepted Solutions

Mooune_DBU
Valued Contributor

If you're referring to Delta Tables, Auto-Optimize will work for both.

For new tables:

CREATE TABLE student (id INT, name STRING, age INT) TBLPROPERTIES (delta.autoOptimize.optimizeWrite = true, delta.autoOptimize.autoCompact = true)

For existing tables:

ALTER TABLE [table_name | delta.`<table-path>`] SET TBLPROPERTIES (delta.autoOptimize.optimizeWrite = true, delta.autoOptimize.autoCompact = true)

If you want this to be the default behavior for all new tables, you can set it as a default setting:

set spark.databricks.delta.properties.defaults.autoOptimize.optimizeWrite = true;
set spark.databricks.delta.properties.defaults.autoOptimize.autoCompact = true;

View solution in original post

2 REPLIES 2

Mooune_DBU
Valued Contributor

If you're referring to Delta Tables, Auto-Optimize will work for both.

For new tables:

CREATE TABLE student (id INT, name STRING, age INT) TBLPROPERTIES (delta.autoOptimize.optimizeWrite = true, delta.autoOptimize.autoCompact = true)

For existing tables:

ALTER TABLE [table_name | delta.`<table-path>`] SET TBLPROPERTIES (delta.autoOptimize.optimizeWrite = true, delta.autoOptimize.autoCompact = true)

If you want this to be the default behavior for all new tables, you can set it as a default setting:

set spark.databricks.delta.properties.defaults.autoOptimize.optimizeWrite = true;
set spark.databricks.delta.properties.defaults.autoOptimize.autoCompact = true;

Sudip94
New Contributor II

I disabled auto optimize in my notebook but still there is auto optimize running when I query describe history {tablename}. I have used the following settings for setting it to false:

spark.conf.set('spark.databricks.delta.properties.defaults.autoOptimize.optimizeWrite', 'false')
spark.conf.set('spark.databricks.delta.properties.defaults.autoOptimize.autoCompact', 'false')
spark.conf.set('spark.databricks.delta.optimizeWrite.enabled', 'false')
 
SET TBLPROPERTIES ('autoOptimize' = 'false', 'targetFileSize' = '16mb', 'optimizeWrite' = 'false', 'autoCompact' = 'false')

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group