Analyze compression and Advisor give different suggestions

0

Hi, I read about ANALYZE COMPRESSION and made this script to analyze and set the recommended compression for all tables, the idea is to run it at night once per month or every 15 days.

I set 3M rows to analyze because there are Tb size tables, so, it seems better than the default 500K.

Something that happened during the last test run is that it set many fields to zstd, and 1/2 days after, Redshift started recommending az64 and bytedict for some of those fields, am I misunderstanding something about how this work? why does the Redshift advisor recommend different settings than analyze compression? Thanks!

[...import...set connection...]
df_tables = pd.read_sql_query('SELECT "table",schema, size, tbl_rows FROM SVV_TABLE_INFO order by size desc',con=con)

for index, row in df_tables.iterrows():
    print(row['schema']+"."+row['table']+" - size: "+str(row['size']))
    df = pd.read_sql_query("ANALYZE COMPRESSION "+ row['schema']+"."+row['table'] + " COMPROWS 3000000", con=con)
    df = df[df.Est_reduction_pct.astype(float) > 9]
    for index2, row2 in df.iterrows():
        try:
            a= "alter table " + row['schema']+"."+row['table'] + " ALTER COLUMN "+ row2['Column'] +" ENCODE " + row2['Encoding'] +";"
            print(a)
            cursor.execute(a)
        except Exception as e:
             print(e)
             con.commit()
質問済み 2年前39ビュー
回答なし

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ