Storing large files in multiple schemas: BLOB or BYTEA
<[email protected]> Wed, 10 Oct 2012 14:12:05 +0400
| Newsgroups | gmane.comp.db.postgresql.php |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
------=_NextPart_000_006E_01CDA6F1.3CF91B60
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi,
I need to store large files (from several MB to 1GB) in Postgres database.
The database has multiple schemas. It looks like Postgres has 2 options to
store large objects: LOB and BYTEA. However we seem to hit problems with
each of these options.
1. LOB. This works almost ideal, can store up to 2GB and allows streaming so
that we do not hit memory limits in our PHP backend when reading the LOB.
However all blobs are stored in pg_catalog and are not part of schema. This
leads to a big problem when you try to use pg_dump with options -n and -b to
dump just one schema with its blobs. It dumps the schema data correctly
however then it include ALL blobs in the database not just the blobs that
belong to the particular schema.
Is there a way to dump the single schema with its blobs using pg_dump or
some other utility?
2. BYTEA. These are correctly stored per schema so pg_dump -n works
correctly however I cannot seem to find a way to stream the data. This means
that there is no way to access the data from PHP if it is larger than memory
limit.
Is there any other way to store large data in Postgres that allows streaming
and correctly works with multiple schemas per database?
Thanks.
------=_NextPart_000_006E_01CDA6F1.3CF91B60
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><META =
HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 14 =
(filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:56.7pt 42.5pt 56.7pt 85.05pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p =
class=3DMsoNormal>Hi,<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>I need to =
store large files (from several MB to 1GB) in Postgres database. The =
database has multiple schemas. It looks like Postgres has 2 options to =
store large objects: LOB and BYTEA. However we seem to hit problems with =
each of these options.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>1. LOB. This =
works almost ideal, can store up to 2GB and allows streaming so that we =
do not hit memory limits in our PHP backend when reading the LOB. =
However all blobs are stored in pg_catalog and are not part of schema. =
This leads to a big problem when you try to use pg_dump with options =
–n and –b to dump just one schema with its blobs. It dumps =
the schema data correctly however then it include ALL blobs in the =
database not just the blobs that belong to the particular =
schema.<o:p></o:p></p><p class=3DMsoNormal>Is there a way to dump the =
single schema with its blobs using pg_dump or some other =
utility?<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>2. BYTEA. These are correctly stored per schema so =
pg_dump –n works correctly however I cannot seem to find a way to =
stream the data. This means that there is no way to access the data from =
PHP if it is larger than memory limit.<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal>Is there any =
other way to store large data in Postgres that allows streaming and =
correctly works with multiple schemas per database?<o:p></o:p></p><p =
class=3DMsoNormal><o:p> </o:p></p><p =
class=3DMsoNormal>Thanks.<o:p></o:p></p></div></body></html>
------=_NextPart_000_006E_01CDA6F1.3CF91B60--