From tigran2-postgres@riatest.com Wed Oct 10 10:12:20 2012 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-- From jdesoi@gmail.com Thu Oct 11 12:59:21 2012 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMIMD-0007JT-6K for pgsql-php@postgresql.org; Thu, 11 Oct 2012 12:59:21 +0000 Received: from mail-yh0-f46.google.com ([209.85.213.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMIM9-0007hm-CD for pgsql-php@postgresql.org; Thu, 11 Oct 2012 12:59:20 +0000 Received: by mail-yh0-f46.google.com with SMTP id m54so440297yhm.19 for ; Thu, 11 Oct 2012 05:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=WpFN8z5VoEWXZRJDbdPlIskEFyk9OyP3X8xFx2jIvf4=; b=Q313PlOtZMcAqWmystsEamuNsAC8ChxV1q3gtyEdvcTPSSzRa0Z7y7F+fFPhKj/dDZ 2Ym4qWguRE+PgD0KVDLVKZKvmY6HJSqSDgbyPJuYhWzqwdp5/s/pMh+lvlpnBbLHGY7+ gLAVr9z9dKvjFDayRigpHS1fxgHjNvKWpt2HyRDtlhs5HesNJyJWDlkioRVWZ7N5p/17 Rq1QHAe5IfDWkLiI+uuJDbefNYnGWAIxkZKnhoQIZibr0k364MhGSta/OjEzibwGxDdr M81SyeD34cni4Y1f7FTVtJ6Iviga1A9YD8frLmnfjJsuJABFwwUby6c+blU7KxjwgrUU RUDg== Received: by 10.236.118.17 with SMTP id k17mr643612yhh.69.1349960356077; Thu, 11 Oct 2012 05:59:16 -0700 (PDT) Received: from [10.0.0.22] (adsl-98-70-101-237.tys.bellsouth.net. [98.70.101.237]) by mx.google.com with ESMTPS id o12sm3666386anp.8.2012.10.11.05.59.15 (version=SSLv3 cipher=OTHER); Thu, 11 Oct 2012 05:59:15 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 6.1 \(1498\)) Subject: Re: Storing large files in multiple schemas: BLOB or BYTEA From: John DeSoi In-Reply-To: <006d01cda6cf$b5e642e0$21b2c8a0$@riatest.com> Date: Thu, 11 Oct 2012 08:59:13 -0400 Cc: Content-Transfer-Encoding: quoted-printable Message-Id: References: <006d01cda6cf$b5e642e0$21b2c8a0$@riatest.com> To: tigran2-postgres@riatest.com X-Mailer: Apple Mail (2.1498) X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201210/5 X-Sequence-Number: 4282 On Oct 10, 2012, at 6:12 AM, tigran2-postgres@riatest.com wrote: > 2. BYTEA. These are correctly stored per schema so pg_dump =96n 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. You can get the octet length and then use the substring function to grab = large columns in chunks. See = http://www.postgresql.org/docs/current/interactive/functions-binarystring.= html John DeSoi, Ph.D. From desoi@pgedit.com Thu Oct 11 13:05:33 2012 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMISC-00026I-UJ for pgsql-php@postgresql.org; Thu, 11 Oct 2012 13:05:33 +0000 Received: from a2s36.a2hosting.com ([216.119.134.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMISA-0000oo-KC for pgsql-php@postgresql.org; Thu, 11 Oct 2012 13:05:32 +0000 Received: from [98.70.101.237] (port=50973 helo=[10.0.0.22]) by a2s36.a2hosting.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.77) (envelope-from ) id 1TMIS7-003Mrx-Bl for pgsql-php@postgresql.org; Thu, 11 Oct 2012 09:05:27 -0400 Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 6.1 \(1498\)) Subject: Re: Storing large files in multiple schemas: BLOB or BYTEA From: John DeSoi In-Reply-To: <006d01cda6cf$b5e642e0$21b2c8a0$@riatest.com> Date: Thu, 11 Oct 2012 09:05:25 -0400 Cc: Content-Transfer-Encoding: quoted-printable Message-Id: References: <006d01cda6cf$b5e642e0$21b2c8a0$@riatest.com> X-Mailer: Apple Mail (2.1498) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s36.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Pg-Spam-Score: 1.8 (+) X-Archive-Number: 201210/4 X-Sequence-Number: 4281 On Oct 10, 2012, at 6:12 AM, tigran2-postgres@riatest.com wrote: > 2. BYTEA. These are correctly stored per schema so pg_dump =96n 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. You can get the octet length and then use the substring function to grab = large columns in chunks. See = http://www.postgresql.org/docs/current/interactive/functions-binarystring.= html John DeSoi, Ph.D.