DE/spark

cache vs persist

sapziling 2022. 10. 31. 10:41

 

 

cache 나 persist 의 필요성 : action을 할때 두번 연산하지 않기 위해. action반복하면 필요

https://stackoverflow.com/questions/28981359/why-do-we-need-to-call-cache-or-persist-on-a-rdd

 

 

cache vs persist 차이 : 저장공간 설정의 차이인듯하다.

https://jhleeeme.github.io/spark-caching/

 

- pyspark에서

 

캐싱 여부 확인

저장공간 확인

print(df.is_cached) -- caching 확인
print(df.storageLevel) -- 저장공간 확인
df.cache() -- 정해진(preset) 저장공간 위치에만 가능
print(df.is_cached) -- caching 확인
print(df.storageLevel) -- 저장공간 확인
df.unpersist() -- cache 삭제
df.persist() -- custom 저장공간에 가능
print(df.is_cached) -- caching 확인
print(df.storageLevel) -- 저장공간 확인
df.unpersist()

reference : https://dbmstutorials.com/pyspark/spark-dataframe-caching.html