Re: store pdf files - Mailing list pgsql-sql

From Andreas Joseph Krogh
Subject Re: store pdf files
Date
Msg-id 200812091918.04751.andreak@officenet.no
Whole thread Raw
In response to Re: store pdf files  (Frank Bax <fbax@sympatico.ca>)
List pgsql-sql
On Tuesday 09 December 2008 18:57:15 Frank Bax wrote:
> ivan marchesini wrote:
> > Hi to all...
> > I need to create a db that contain link to some pdf files..
> > At the moment these are simple links (to the files that are stored into
> > the file system) storing paths into a column of a dbf table...
> >
> > I need to manage this data considering that the db I'm going to create
> > will be moved in some months to another server...
> > so I think that the link to the files positions into the file system
> > isn't a valid solution...
> >
> > can you suggest me a better way to manage this pdf data??
> > Each pdf is quite small (<100k)
> >
> > should I use BLOB?
>
>
> Leave the files on filesystem and code the highest level directory into
> a function.

Absolutely not. You'll loose transactional safety the DB provides. That reason alone is good enough to justify storing
thefiles in a BLOB (BYTEA in PG). 

The length(BYTEA)-function in PG can be used to retrieve its length. It is IMMUTABLE and "constant time", which means
youcan apply a functional-index on it. That way you don't need to store the size of the file in a separate column. 

--
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+


pgsql-sql by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: store pdf files
Next
From: Richard Huxton
Date:
Subject: Re: inconsistent automatic casting between psql and function