Re: Storing files in postgres db

From: Michal Taborsky - Internet Mall <michal(dot)taborsky(at)mall(dot)cz>
To: tam wei <twxtam(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Storing files in postgres db
Date: 2006-12-04 13:18:09
Message-ID: 45742011.1040302@mall.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Tam Wei,

tam wei wrote:
> I am intending to store the files inside the postgres DB using the
> type text (all the files will be pre-encode into base64. The reason
> for not using the type bytea as I encountered some undesired
> format(the original file alignment can't be preserved) while
> extracting the content and display iit using php).

You must be doing something wrong on PHP side. Make sure you use
pg_escape_bytea/pg_unescape_bytea when storing/loading. We use it and it
works with binary files, no problem. You are wasting space and slowing
things down with base64.

> Will it be a bad idea for storing the files in DB? the file size is
> about 20 ~ 40 KB. 3K files need to be stored per day. Is there any
> impact on the DB performance?

We use it to store files of 50MB without any difficulty. It all depends,
of course, on your hardware and load.

--
Michal Táborský
chief systems architect
Internet Mall, a.s.
<http://www.MALL.cz>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2006-12-04 13:24:10 Fix for 8.2 release. Was: Problems to create the portuguese dictionary
Previous Message Mark Morgan Lloyd 2006-12-04 12:36:06 Re: Locking for function creation