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!

asked 6 months ago319 views
2 Answers
1
Accepted Answer

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
EXPERT
Ziad
answered 6 months ago
profile picture
EXPERT
reviewed 6 months ago
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
answered 6 months ago
  • Ah, I got it, thanks a lot @MilindOke

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions