pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <postgresql@aranya.com>
To: Postgres SQL language list <pgsql-sql@postgresql.org>
Subject: Storage of Binary Data
Date: Tue, 25 Jul 2006 12:05:37 -0500
Message-ID: <bf05e51c0607251005i58e836b7u51f411e103c242@mail.gmail.com> (raw)

I have a somewhat philosophical question about best practices when storing
binary data.

For my web projects, we have been storing binary data (like images, PDF's,
etc) on the hard drive of the web server instead of the database.  Within
the database, we keep information, like whether an image is present, in a
separate column.

For example:

CREATE TABLE site_user (
   site_user_id BIGSERIAL NOT NULL,
   has_profile_image BOOLEAN DEFAULT false NOT NULL
   CONSTRAINT site_user_pkey PRIMARY KEY (site_user_id)
);

And then store the profile image at:

   [web root]/images/siteuserprofile/profile-[site_user_id here].jpg

We also have a back end process that then checks these files into CVS to
help maintain version control.

My questions are:
* What other options are people using to store data like this?
* What are the advantages/disadvantages of these storage methods?

I have been very reluctant to store the binary data in the database for the
following reasons:
* Performance because you cannot just save the data to the file system, you
must
   interact with the database to get/save contents
* Increases complexity of application
* I have had problems with saving binary data using JDBC before (that was
with
   Oracle 7 though)
* I am concerned about how well the data backups will work - there have been
several
   people who have had problems with backing up and restoring binary data on
this
   list

I am trying to develop some best practices so any input you guys have is
welcome!

Thanks

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
==================================================================

view thread (2+ messages)  latest in thread

Message-ID: <bf05e51c0607251005i58e836b7u51f411e103c242@mail.gmail.com>
Permalink:  ../bf05e51c0607251005i58e836b7u51f411e103c242@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0607251005i58e836b7u51f411e103c242@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgresql@aranya.com
  Subject: Re: Storage of Binary Data
  In-Reply-To: <bf05e51c0607251005i58e836b7u51f411e103c242@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox