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회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠