Re jcoby answer:
bytea, which is a “normal” column, also means that the value is read completely into memory when it is retrieved. Blobs, in contrast, you can pass to stdout. This helps reduce server memory. Especially when you save 4-6 MPix images.
No backup issues. pg_dump provides the -b option to include large objects in the backup.
So, I prefer to use pg_lo_ *, you can guess.
Chris Erickson's answer:
I would say the opposite :). When images are not the only data that you store, do not store them in the file system unless you need to. Such an advantage is always to be aware of your data consistency and have data "in one piece" (DB). BTW, PostgreSQL is great for maintaining consistency.
However, the truth is that reality is often too demanding on performance ;-) and this forces you to serve binary files from the file system. But even then, I am inclined to use the database as the “main” storage for binary files, and all other relations are sequentially connected to each other, while providing some kind of file system-based caching mechanism to optimize performance.
Ivan Krechetov Sep 19 '08 at 6:21 2008-09-19 06:21
source share