Re: Storing a kazillion small blobs in postgresql. Smart?

From: Steve Atkins <steve(at)blighty(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Storing a kazillion small blobs in postgresql. Smart?
Date: 2006-02-11 17:50:31
Message-ID: 7B6529FA-FAC1-4E10-A467-A62050762201@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Feb 11, 2006, at 9:41 AM, Stefan Arentz wrote:

> Hi there,
>
> I'm looking at the design for an application where i have to store
> potentially many gigabytes worth of small blobs of varying sizes
> (8K - 64K) in a database. I've always been told that it is smarter
> to store references to files in the database, and I think that is
> true in a lot of cases. But here I need this data to be
> transactional and probably replicated so I'm looking into storing
> it directly in the db.
>
> I know this is all rather vague but I'm interested in more
> experienced pgsql user's opinions about this. Is it smart? Would it
> work? Or would something like this blow up the db?

It would work just fine. Postgresql is pretty good at handling larger
data elements like this, and will transparently behind the scenes store
them in a look-aside table, compressed and pointed to by the main
table (look for TOAST in the manual for the full info).

For smaller chunks of data I'd use text fields if they're text, bytea
fields id they're non-text.

You can use "large objects" too, but I suspect the additional
features they offer (the ability to read just part of the object, say)
would be far outweighed by the inconvenience in using them
compared to bytea for your app. (They also tend to be less
well-supported by some client interfaces).

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-02-11 17:59:19 Re: Sequence skipping values
Previous Message Leonel Nunez 2006-02-11 17:46:45 Re: Storing a kazillion small blobs in postgresql. Smart?