Re: Re: pictures stored in PostgreSQL DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Mon, 2007-03-05 at 10:16 -0500, Mark wrote:
>> Alain Roger wrote:
>>
>> > Hi,
>> >
>> > It's amazing that my previous post has raised so much consideration
>> about
>> > the fact to store or not pictures into DB.
>>
>> And yet you ask again!? Did you not learn? No good can come from this
>> question.
>
> He didn't care about the debate. He is already using a database and
> wants to display the images. I'm sure he learned plenty, but not what he
> wanted to learn.

"I gained nothing at all from supreme enlightenment - and for that very
reason, it is called supreme enlightenment"

Buddha.

> I'd say the most important outcome of the side-track
> debate was to clarify that it depends on what you are working with, what
> you are doing, what your tolerance is for various types of solutions,
> and where those tolerances lie. An important thing we also learned, is
> that while filesystem storage is often the better solution, it is not
> always the best solution, especially when factoring in such things as
> convenience and simplicity.

I don't think we came to any such conclusion. I still assert that while
there may be multiple "right" ways to accomplish a task, there are often
clearly "wrong" ways. Putting bitmap data inside the database is a
mistake.

Before y'all got hyper-literal trying to argue the finer details of the
definition of "mistake," my assertion is this:

I have yet to see one implementation or strategy where putting bitmap data
in a database can not be accomplished more efficiently using a different
approach. Bitmap data does not belong in a SQL database because it is not
something that is of any use to the algebraic relational syntax of SQL,
thus it is more efficient to store a reference to the data rather than the
data itself.

Putting database data in the database needlessly increases load on the
database. If you are using MySQL, the tables in which the bitmap is stored
are read-locked during the read of the data. If the data is large, it can
use up buffering resources otherwise used to increase query performance.

Bitmap image data can not be incorporated into the HTML stream with the
rest of the data retrieved. A reference must be created in the HTML
document so that the client web browser can issue a new HTTP request for
the image. It is more efficient to put a reference in the database and
have the browser query directly for the image against a file based system.

SQL databases don't use normal data access methods to access large binary
data, in PostgreSQL TOAST is used, in MySQL they are read as their own
data blocks, and in Oracle they are sometimes put in different table
spaces. Anyway you slice it, they are less efficient than normal "data."

If you can't come up with a scenario that disproves the previous
assertions, then you aren't arguing the point and creating strawmen in an
effort to avoid the real issues.

>
>> > However, none of those posts answered to my question... How can i
>> retrieve
>> > and display those pictures to my PHP pages ?
>> >
>> > Basically, on my PHP page I have some texts and I would like to
>> extract
>> > from DB the pictures to display.
>> > Therefore, set the header to mine JPEG or GIF does not allow to have
>> text
>> > also.
>>
>> This is another problem with images in databases, unlike text or data
>> which
>> can be incorporated into the HTML output stream, an image needs to be
>> its
>> own file.
>
> Image doesn't need to be it's own file,

Again, don't get hyper-literal, by file, as used in this post, I meant
file as seen by the browser which is represented by a URL and causes a
HTTP request.

[snip]

>
>> You will have to hit the database twice. Once to render the page, and
>> again
>> to render the image.
>>
>> To render the image you need to query the database and send the data
>> back on
>> its own, but before you do, you have to set the content type header to
>> jpeg, gif, or whatever.
>>
>> This is why I say image data does not belong in the database.
>
> Boooooooooooooooooring.

Actual answers to actual problems are usually boring.

> Belongs wherever the developer or the business
> requirements want to store it.

Yea, and 1+1 = what ever the engineer or the business requirements want it
to be, right?

This is engineering, not art class. There are ways to evaluate solutions
as being better than others.

[snip]

>
>> > So please, how can i do to display pictures from DB, when my PHP page
>> also
>> > include texts and other images (from filesystem) ?
>> >
>> > In fact i would like to do something like a thumbnail...
>>
>> You will need to repeat the same steps outlined above, but use image
>> manipulation utilities to reduce the image. Again, that's why you store
>> images in files and not in the database.
>
[snip]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux