Re: Filesystem vs. Postgres for images

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: Filesystem vs. Postgres for images
Дата
Msg-id 20040414154403.GB18171@gp.word-to-the-wise.com
обсуждение исходный текст
Ответ на Re: Filesystem vs. Postgres for images  (Alex <alex@meerkatsoft.com>)
Список pgsql-general
On Wed, Apr 14, 2004 at 10:15:51PM +0900, Alex wrote:
> Hi,
> is the file system approach really easier and faster? What if you need
> to protect the image data e.g. you dont want users just to just dowload
> the pictures directly from your website?

It can be much faster, if implemented correctly, to put the large
files directly on the filesystem. It makes it a little harder to cluster,
but it can significantly reduce DB overhead.

There's no issue with the users downloading images directly, as you
normally wouldn't mount them directly into the URL namespace. Instead
the URL would point to a script that would lookup the image in the
database, and check permissions. If the user is allowed to load the
image the script will close it's connection to the database, and start
shoveling bytes from the filesystem to the http connection. Most
decent web application platforms have some amount of support for this
sort of thing built in.

That has a number of other advantages too - it can take a long time
for a user to download a large file, and you really don't want the
thread handling them to tie up a database connection for all that
time.  If you're on a platform that supports nice things like
sendfile(2) you can even have the kernel do almost all the work.

Cheers,
  Steve

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: db schema diff
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Donating