Search code examples
storageclonesnowflake-cloud-data-platform

Owned Storage vs Referenced Storage


Looking at this page in the Snowflake docs: https://docs.snowflake.com/en/user-guide/tables-storage-considerations.html#owned-storage-vs-referenced-storage ...

If T2 is cloned from T1 and then data is changed in T2, T2 is the owner of that changed data.

If T3 and T4 are both cloned from T2 and then T2 is dropped, is the data that T2 owned then duplicated between T3 and T4 and both own their copies of that data?

If not, how does this work?

Thanks


Solution

  • I assume you are referring to which table the storage of the data is associated to. When a table is dropped, the storage elements are not deleted unless no other tables (clones) reference that data. The only thing that is deleted is the reference to that data. So, if you have T3 and T4 as clones to T2, and then T2 is dropped, T3 and T4 will still reference the micropartitions that were contained in T2. They are not duplicated.

    Ownership of the micropartitions is really just for accounting the storage to a particular table. In your example, the T2 micropartitions will have the ownership transferred to whichever clone was created first (T3 or T4, not both). This is all a metadata operation in Snowflake that happens behind the scenes.