From: | tv(at)fuzzy(dot)cz |
---|---|
To: | François Delpierre <pgsql(at)pivert(dot)org> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: How to store files into the DB with PHP. (bytea ?) |
Date: | 2009-02-02 13:17:38 |
Message-ID: | 5713.193.179.187.70.1233580658.squirrel@sq.gransy.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
>> Choice between BYTEA and LOB is mostly about memory requirements - when
>> loading / storing BYTEA columns, you need enough memory to keep the
>> whole
>> object (data stored in the column). So when constructing the INSERT
>> statement you have to place the (escaped) data into it, and that may
>> exceed the memory_limit. With LOB objects this is not a problem thanks
>> to
>> streaming (you may open the LOB as a stream and read / write).
> So, there is no way to push binary directly into BYTEA without the need to
> escape ?
AFAIK no (at least in PHP) - you have to escape the data before using them
in SQL statement.
> I assume that you're talking about memory_limit parameter of PHP on the
> web
> server.
> Can we still use streaming through a stored procedure ?
The LOB principle is quite simple - each LOB is identified by OID, split
into multiple segments and stored in a table pg_largeobject. I am just
guessing but there are functions used to read / store the LOBs, so the
streaming might work (unless you want to use the tickets).
But I am just guessing - about a month ago I wrote an article about ways
to store files in a PostgreSQL database:
http://www.fuzzy.cz/en/articles/storing-files-in-a-postgresql-database/
The site is still under construction, so a lot of stuff is missing there
(sorry), but the last section might give you a hint how to mimic LOBs, get
rid of some of the BYTEA / LOB disadvantages.
>> Sorry, but you have some custom layer of stored procedures, so we may
>> only
>> guess. But LOBs are identified using an OID, so the procedures might
>> return OIDs.
> The web server user cannot read (or write) any table directly, so it's
> forced
> to use a stored procedure to read or write data. So, all the PHP fuctions
> on
> LOB are useless I guess.
From | Date | Subject | |
---|---|---|---|
Next Message | François Delpierre | 2009-02-02 14:13:10 | Re: How to store files into the DB with PHP. (bytea ?) |
Previous Message | François Delpierre | 2009-02-02 12:55:34 | Re: How to store files into the DB with PHP. (bytea ?) |