-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADAP-1006] [CT-3321] DBT Models are not using Snowflake Result Cache/Query Cache #825
Comments
Did your Snowflake Warehouse turn off between the 2 calls? (e.g. you might have a setting to auto suspend it after 1 min of inactivity). I believe that the cache is only valid if the Warehouse was not turned off. |
@b-per No the warehouse didn't suspend between the runs. Even if it would have, Result Cache is not dependent on Warehouse activity but only the 24 hrs time window and base table micro partitions. https://docs.snowflake.com/en/user-guide/querying-persisted-results |
Thanks for the update. I got confused with the Warehouse cache which is only available for the time a warehouse is on. Warehouse caching can definitely help get some following queries run faster. I don't think that there is anything that dbt can do with what you see. I went directly in Snowflake (so, not using dbt), and ran multiple times in a row If I just run So, reusing persisted results doesn't seem to be possible when used as part of DDL statements. |
Thanks for reaching out about this @ankitsr92. Based on your description, it sounds like you are doing the following?
If so, then what happens if you do the following instead?
Does it result in a cache hit or a cache miss? |
Adding a test scenario: -- create some dummy data
create or replace table test as
select dateadd(day,
row_number()
over (order by seq4()),
'1899-12-31'::date) as d_date
from table(generator(rowcount => 109573));
select * from test; -- uses warehouse to compute
select * from test; -- no warehouse because of result cache
create or replace table test2 as
select * from test; -- uses warehouse
create or replace table test2 as
select * from test; -- uses warehouse The first select query (second to last one in the screenshot) is using the warehouse to return data. The third to last one doesnt use a warehouse because the query is returned from the result cache. Adding a |
Is this a new bug in dbt-core?
Current Behavior
Snowflake Query Cache states that if the a query is run multiple time within 24 hrs window across any warehouse result would be produced through result cache. Given the source table data has not changed.
When it comes to DBT Models, I executed my models once. Upon executing the models again in next 5 min I still see model sql's being executed and taking the same amount of time as Run 1. The base tables again have not changed this time.
Is it not contrary to Snowflake behaviour? Is it something with DBT backend code which is restricting this?
Expected Behavior
Upon re-run dbt models again within 24 hrs time and with unchanged base tables, Snowflake query cache should be used and it should take considerably less amount of time compared to first run.
Steps To Reproduce
Run any DBT Model on Snowflake
Run the model again post Run 1 completion
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: