SnowPro Advanced: Architect — Question 121
The result cache is not being used on the following query:
select * from ORDERS Where O_ORDERDATE = date_trunc('day', current_timestamp());
The query is run hundreds of times a day by several different Analyst teams. The team members use different roles and warehouses. The table is updated once every month.
What can be done to ensure that the query uses the result cache?
Answer options
- A. Create a view on the table with the definition create view curr_orders as select * from ORDERS Where O_ORDERDATE = date_trunc ('day', current_timestamp ()); Then use the query SELECT * from curr_orders;
- B. Have all users reuse the same virtual warehouse.
- C. Assign the same user role to all Analysts.
- D. Change the query to select * from ORDERS Where O_ORDERDATE = current_date ();
Correct answer: D
Explanation
The correct answer is D because using current_date() allows the query to leverage result caching, as it results in a more stable value that can be reused across different executions. The other options do not directly address the caching mechanism, as they focus on user roles or warehouse configurations, which do not impact how the SQL query is processed.