r/nocode • • 3d ago

Question Storing generated PDFs in Postgres vs object storage: where do you draw the line?

/r/n8nforbeginners/comments/1y6s8sq/storing_generated_pdfs_in_postgres_vs_object/
2 Upvotes

9 comments sorted by

2

u/suubu-crtiv 2d ago

i'd default to object storage like s3 and keep just the key, size and checksum in postgres. bytea is ok under ~1MB at low volume, but backups and replication bloat up fast beyond that.

1

u/easybits_ai 2h ago

Thanks for sharing this! I've heard of bytea before, but I'm still not entirely sure whether it's the right fit for my use case. I'll definitely look into it more closely, though.

2

u/Rishiraj-Tshaka 2d ago

for low volume internal tools, keeping it in the database is totally fine imo. the main annoyance you'll actually hit first isn't query speed, it's database backups getting bloated and slow.

1

u/easybits_ai 2h ago

I'll keep an eye on this for a bit longer, but for now, I've decided to stick with the database and base64 approach. I did create a separate table to store the base64 strings, though, as I didn't want them to affect the performance of the main tables.

2

u/Common-Potential2441 2d ago

Keep it in Postgres at your volume. A few PDFs a month won't hurt you, and backups already cover them. I'd move to object storage when row size starts dragging queries or backups, not before.

1

u/easybits_ai 2h ago

Thanks so much! That's exactly what I did as well, and I'm keeping a close eye on the performance to make sure nothing starts slowing down.

3

u/AnswerVinod 2d ago

i have been on both sides of this one. base64 in postgres is fine while it is a few pdfs a month, it keeps life simple and backups cover everything in one place. the line for me is when the table starts getting big or downloads get frequent, base64 also bloats every row by about a third and slows your backups down. then i move the file to object storage and keep only the key, size and checksum in the row, like others said. generate once at approval is the right call either way, never pay for the conversion twice.