<?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: Running vacuum on each table in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28417#M20213</link>
    <description>&lt;P&gt;Thanks for the elaborate explanation . &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍🏼&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 14:38:38 GMT</pubDate>
    <dc:creator>sapote</dc:creator>
    <dc:date>2022-02-14T14:38:38Z</dc:date>
    <item>
      <title>Running vacuum on each table</title>
      <link>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28415#M20211</link>
      <description>&lt;P&gt;Hi, in line with my question about &lt;A href="https://community.databricks.com/s/feed/0D53f00001hJKKNCA4" alt="https://community.databricks.com/s/feed/0D53f00001hJKKNCA4" target="_blank"&gt;optimize&lt;/A&gt;, this is the next step, with a retention of 7 days I could execute vacuum on all tables once a week, is this a recommended procedure?&lt;/P&gt;&lt;P&gt;How can I know if I'll be getting any benefit from vacuum, without DRY RUN that runs all the process but skips the final part when it deletes the files.&lt;/P&gt;&lt;P&gt;And anyone have a script to share to iterate on each table and run a command, I find similar sample scripts but nothing in spark.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Feb 2022 21:35:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28415#M20211</guid>
      <dc:creator>alejandrofm</dc:creator>
      <dc:date>2022-02-12T21:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Running vacuum on each table</title>
      <link>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28416#M20212</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally 7 days is recommended, but discuss with data stakeholders to identify what's suitable? 7/14/28 days. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use VACCUM, first run some analytics on behaviour of your data.&lt;/P&gt;&lt;P&gt;Identify % of operations that perform updates and deletes vs insert operations. This will tell you how many files aren't being referenced anymore, and a cleanup is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To understand the efficiency of VACCUM run queries before and after VACCUM operation. Does it improve the performance time? Maybe try doing VACCUM at different intervals 7/14/28 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And definitely use VACUUM if there's a requirement to wipe out the data of system for particular scenarios.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As such there's no script. But, you can try this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
#get list of all tables
table_list = spark.sql("show tables from &amp;lt;database name&amp;gt;").select('tableName').rdd.map(lambda x : x[0]).collect()
&amp;nbsp;
for table in table_name:
  spark.sql(f"VACCUM {}".format(table))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 13:22:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28416#M20212</guid>
      <dc:creator>AmanSehgal</dc:creator>
      <dc:date>2022-02-14T13:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running vacuum on each table</title>
      <link>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28417#M20213</link>
      <description>&lt;P&gt;Thanks for the elaborate explanation . &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍🏼&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 14:38:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/running-vacuum-on-each-table/m-p/28417#M20213</guid>
      <dc:creator>sapote</dc:creator>
      <dc:date>2022-02-14T14:38:38Z</dc:date>
    </item>
  </channel>
</rss>

