Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLtH2-0003md-E1 for pgsql-php@postgresql.org; Wed, 10 Oct 2012 10:12:20 +0000 Received: from riatest.com ([68.169.46.79]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLtGw-0000Ql-1e for pgsql-php@postgresql.org; Wed, 10 Oct 2012 10:12:19 +0000 Received: from Tigran (unknown [46.70.121.64]) by riatest.com (Postfix) with ESMTPSA id 48976800C2 for ; Wed, 10 Oct 2012 11:12:10 +0100 (BST) From: To: Subject: Storing large files in multiple schemas: BLOB or BYTEA Date: Wed, 10 Oct 2012 14:12:05 +0400 Message-ID: <006d01cda6cf$b5e642e0$21b2c8a0$@riatest.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_006E_01CDA6F1.3CF91B60" X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac2mz3lzROcbRQTIRvqc3O5mPkcyOw== Content-Language: en-us X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201210/3 X-Sequence-Number: 4280 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

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--