# Dataframe write performance to Postgres

**URL:** <https://discuss.dataengineercafe.io/t/dataframe-write-performance-to-postgres/689>\
**Category:** พูดคุยเกี่ยวกับ Data Tools ต่าง ๆ\
**Tags:** spark\
**Created:** [March 17, 2024, 8:58am UTC](https://discuss.dataengineercafe.io/t/dataframe-write-performance-to-postgres/689 "2024-03-17T08:58:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kahnwong](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.dataengineercafe.io/kahnwong/32/295_2.png) [@kahnwong](https://discuss.dataengineercafe.io/u/kahnwong)\
**Post date:** [March 17, 2024, 8:58am UTC](https://discuss.dataengineercafe.io/t/dataframe-write-performance-to-postgres/689/1 "2024-03-17T08:58:55Z")

</div>

เคยทำ spark vs polars วัดสปีดตอนปั่นดาต้าไปแล้ว เลยมาวัดสปีดตอนเขียนลง postgres ต่อ

พบว่า จริงๆ polars ก็ไวกว่านิดหน่อย แต่ก็และมากับ RAM ที่งอกเป็นเงาตามตัว

และ ข้อเสียอีกอย่าง คือ ถ้าจะเขียนจาก polars ตรงๆโดยไม่แปลงเป็น pandas ก่อน (เพราะ sqlalchemy adapter จะใช้ผ่าน pandas, แต่ถ้าใช้ adbc adapter จะเป็น arrow ตรงๆ เลย ไม่ต้องแปลง) ก็จะเขียนลงได้แค่ sqlite หรือ postgres

จริงๆ พบว่า ส่วนใหญ่ big data ไม่ได้มีเยอะขนาดนั้น ถ้าใช้ postgres แล้วไหว ก็ไม่เป็นไร แต่ถ้ารู้สึกว่า analytics query เริ่มอืด อาจจะต้องเตรียม migrate ไปใช้ spark และ columnar warehouse

โพสเต็ม: [Dataframe write performance to Postgres | Karn Wong](https://karnwong.me/posts/2024/03/dataframe-write-performance-to-postgres/)
