Database versus filesystem for storing images - Mailing list pgsql-general

From Clodoaldo
Subject Database versus filesystem for storing images
Date
Msg-id a595de7a0612311316m67e99669m2cd2d53d1ce94d90@mail.gmail.com
Whole thread Raw
Responses Re: Database versus filesystem for storing images  (Guy Rouillier <guyr-ml1@burntmail.com>)
Re: Database versus filesystem for storing images  (Scott Ribe <scott_ribe@killerbytes.com>)
List pgsql-general
A web application will store hundreds of thousands images.

The images meta data will be stored in postgresql but I'm in doubt
about where to store the images themselves, if in the database as byte
strings or in the file system.

Would one of them have a faster image search than the other?

In the database the images would be indexed by a serial id, that of
the file submitter, and an image number. They would always be searched
by the same key.

In the file system there would be a two or three level directory
structure and the directory names would be hexadecimal numbers like
'/images_directory/f/0/d' taken from the 2/3 first letters of the file
name, which would be a hash.

Whenever I want to know the hash name of an image so I can find it in
the file system I would have to search it first in the database by the
index. So I suppose the database will always be faster.

But there is an advantage in using the file system. It is that the
Apache's HTTP file caching management is there for free. If I store
the images in the database I will have to handle the request and
response HTTP headers myself if I want the images to be cached by the
clients.

What is the best practice in this situation? I mean not only the two
options as above but any.

Regards,
--
Clodoaldo Pinto Neto

pgsql-general by date:

Previous
From: novnov
Date:
Subject: Re: Generic timestamp function for updates where field
Next
From: novnov
Date:
Subject: Installing support for python on windows