Does RedShift support compilation cache for similar queries, how?

0

I read the RedShift Paper: [https://assets.amazon.science/93/e0/a347021a4c6fbbccd5a056580d00/sigmod22-redshift-reinvented.pdf] (redshfit re-invented). In chapter 2.6 Compilation Service:

When the same or similar queries are executed, the compiled segments are reused from the cluster code compilation cache

I'm wondering how to identify similar queries?

A query with only parameters different is identified as similar queries?

e.g.

query1: select c1, sum(v1) from t where c2='AAA' group by c1; 
query2: select c1, sum(v1) from t where c2='BBB' group by c1; 
query3: select c1, sum(v1) from t where c2 in ('AAA') group by c1; 

query2 is similar to query1, but query3 is not similar to query1?

Any help would be appreciated!

已提問 7 個月前檢視次數 336 次
2 個答案
1
已接受的答案

Hi stanleyhunju,

There is no defined or specific list of conditions for similar queries. In your example, query 3 is considered similar to query 1 since they are searching for the same results or dataset but in a slightly different way. If you first execute query 1 and then query 3, query 3 in this case will use the result cache.

I usually use the system view SVL_COMPILE to analyze the compilation phase of queries.

Regards, Ziad

AWS
專家
Ziad
已回答 7 個月前
profile picture
專家
已審閱 7 個月前
1

Redshift query engine can rewrite the queries before execution. It will see that query 3 is similar to query 1 and can be rewritten to match it. Thus it can still leverage the compile cache for query 3.

profile pictureAWS
已回答 7 個月前
  • Ah, I got it, thanks a lot @MilindOke

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南