Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMz0j-0004CN-FJ for pgsql-general@arkaria.postgresql.org; Wed, 14 Nov 2018 17:31:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMz0g-00087V-Kd for pgsql-general@arkaria.postgresql.org; Wed, 14 Nov 2018 17:31:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMykC-0002vI-7Q for pgsql-general@lists.postgresql.org; Wed, 14 Nov 2018 17:14:24 +0000 Received: from mail-eopbgr760041.outbound.protection.outlook.com ([40.107.76.41] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMyk2-0000q8-Qv for pgsql-general@lists.postgresql.org; Wed, 14 Nov 2018 17:14:22 +0000 Received: from CY1NAM02FT057.eop-nam02.prod.protection.outlook.com (10.152.74.51) by CY1NAM02HT210.eop-nam02.prod.protection.outlook.com (10.152.74.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1339.15; Wed, 14 Nov 2018 17:14:12 +0000 Authentication-Results: spf=pass (sender IP is 104.156.72.34) smtp.mailfrom=ultra-ft.com; anayrat.info; dkim=none (message not signed) header.d=none;anayrat.info; dmarc=bestguesspass action=none header.from=ultra-ft.com; Received-SPF: Pass (protection.outlook.com: domain of ultra-ft.com designates 104.156.72.34 as permitted sender) receiver=protection.outlook.com; client-ip=104.156.72.34; helo=SRV-CAMTL-EXCH2.Forensictech.com; Received: from SRV-CAMTL-EXCH2.Forensictech.com (104.156.72.34) by CY1NAM02FT057.mail.protection.outlook.com (10.152.75.110) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1339.15 via Frontend Transport; Wed, 14 Nov 2018 17:14:10 +0000 Received: from SRV-CAMTL-EXCH2.Forensictech.com ([172.30.10.87]) by SRV-CAMTL-EXCH2.Forensictech.com ([172.30.10.87]) with mapi id 14.03.0415.000; Wed, 14 Nov 2018 12:14:08 -0500 From: Jean-Marc Lessard To: Adrien Nayrat , "pgsql-general@lists.postgresql.org" Subject: RE: pg_dump out of memory for large table with LOB Thread-Topic: pg_dump out of memory for large table with LOB Thread-Index: AdR4hmQrnxoMiqbATW2nddPcBUDX1gBSuJoAAJr9+sA= Date: Wed, 14 Nov 2018 17:14:07 +0000 Message-ID: <8FC5F25FF3EC4744ADFCF20CBA3F44BE016811C1EF@SRV-CAMTL-EXCH2.Forensictech.com> References: <8FC5F25FF3EC4744ADFCF20CBA3F44BE016811BCEF@SRV-CAMTL-EXCH2.Forensictech.com> <73d2f4fb-3da4-1c09-8bff-88a35f16bcd2@anayrat.info> In-Reply-To: <73d2f4fb-3da4-1c09-8bff-88a35f16bcd2@anayrat.info> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.30.33.140] x-c2processedorg: 845c9e2e-433d-4b81-a451-faf8842d96b4 Content-Type: multipart/alternative; boundary="_000_8FC5F25FF3EC4744ADFCF20CBA3F44BE016811C1EFSRVCAMTLEXCH2_" MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:104.156.72.34;IPV:NLI;CTRY:;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(396003)(376002)(136003)(39840400004)(2980300002)(438002)(199004)(189003)(55846006)(71190400001)(6116002)(3846002)(69596002)(126002)(72206003)(86362001)(316002)(102836004)(478600001)(110136005)(16586007)(14454004)(2900100001)(2906002)(446003)(53416004)(2920100001)(486006)(6246003)(66574009)(2501003)(356004)(476003)(606006)(229853002)(11346002)(53386004)(5660300001)(84326002)(77096007)(15974865002)(55016002)(9686003)(6306002)(236005)(7736002)(54896002)(8936002)(14444005)(104016004)(33656002)(336012)(186003)(7696005)(106002)(106466001)(81156014)(8676002)(81166006)(26005)(76176011);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1NAM02HT210;H:SRV-CAMTL-EXCH2.Forensictech.com;FPR:;SPF:Pass;LANG:en;PTR:ip-34-72-156-104.static.fibrenoire.ca;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT057;1:o4/nIUVH9yuYdkrg5Ufqy3alK8doXzAovBtr9enHAnxVzgyMgjWFMazsOdDt7ehFn1bieyhQCqgNHVYjP+7sSuDV9uNSj6WYjiG3PboJcQRfiJje7UY2OU5uu39+EjqA X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51790ec5-be59-444c-5d89-08d64a549833 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060)(7193020);SRVR:CY1NAM02HT210; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02HT210;3:r3jkXvhPIjBH4UC6ryUJdQc7YtDb4a8a7N/19XkamB1Ca3DPREAFOX3dymjr9l8sPXdY/flHNsrDQ6I74FOmbNctsMDhy0I27ASgg6NZ3gIK5AjAIdEeqEgcN9FMv/6LgGBVRJqkal+UGI8iN5ouAUa4gvRmW/dAN9+F4cTvuVK2TCi5oOT9TNh9j5aosrBDdCGJs6t9BE5dPIoADf98UWBtH2GcHw72rB1VLBf/FXt2zxnz2MYUB5oEktc/qYXsSELFgXoaZIMDQwhvMnDHdhM4wYu0Q4+vaU0zAGeS9wcf6t6VDdUdKB1nFEGQgVJROBev8HDzv0Ik24mMrmqOJA==;25:UZOOWAiIth2GLRC/0RWE/Edx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PL6wn/g8zcOgA+XmB3jYE6L5x5WoIaSxWp5ZleuY4Kxmc8VbGiB1NaaxtBAU6YevwJviU+KoGYnOXJiLM1FvNCZB1jROd1Am7Hbpgz95U7dszXUNCqISnI2tch/bRhq7GwAe7mqh8x9koQf4teradCY0z6swbYRp8ylqZV7U=;4:tIr1+Bo6HBc8PJrR3ce60G8ejbOhowiDcGtAqYE3UCzl1TwS3xzB1H+/YqUdssHv3G/mCMTPNxTOvGNJ/c7giz3LWke2ineE8IyT6c0vc4LZFK0twB3y0M80yk18aPsp5CgRNcV/YORj2If0tr92IZdqFG1SiplPAi+OHQFVg+/EHdVHN7Kau3xqZPHCrkeRnsarKl58LuZ1bfZ+X6VFp+gW7wmREycucYnLtXZCRTc0YDoU1bcioVXOpUCQ50L0RLJkPge1bpg9RarYl2zVZQ== X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231412)(944501410)(4982022)(52105112)(3002001)(93006095)(93004095)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:CY1NAM02HT210;BCL:0;PCL:0;RULEID:;SRVR:CY1NAM02HT210; X-Forefront-PRVS: 085634EFF4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1NAM02HT210;23:5Pos+ZM5GpaCRXdShUIVKps1MVnMOfz0DrHCSuZZV?= =?us-ascii?Q?9ObP/3RmKLqNmOwjav2NNnaME3arhOE+jiSYW9uZHqTe4/M8F/cpPRJ4g4/J?= =?us-ascii?Q?/J7DH0pcyUYIhb0n7k18stlkjNijMasU7n6OZDdUIlNydMJqKsEr9F3vou21?= =?us-ascii?Q?f8n6rbjxX+qzvumo/KODi7H0ksjSc5ztG+ZRsEwSgNTtTqsmQUY+/+Lyf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afKO4P3iA4ABAwG1kGh6TPt2MFVyDzTCtVI3O1t1Hi3fm8IM9c4Qw/l5esccbvSTTzXfQM3AeHZbIA8eKw2llRthJkxkSvkk4KW/DlIRrrrPZFueWyB0GRsd29Q6R12l/fa/zcaw1g2u1JPM85bWj8Itcyu31cvGX0w==;5:IunhDKYgIkzJ7TJLiZmvDvpONX2nWuw3dGiJEpTLXJYug1KLyKqC/1zSKWThMdFrD4XOyacaN6u0+BFrA3lziNnSHRUM5lZmN4s6HK3GDHMAFJjcAMm3k76ffXdJ6vE1N5LSlQg74expGK1TK3aJzgsaEZeKJ8OhJDH+Rhkd49k=;7:7Z34tyLVoHZ5dLcxAAArWFKzbnA2st/hCZcOcG7pII0qdXAaZtiJ7UX2PhCQ3KWGfnEyBgo4nxBUoJUO86Gn/MV4x4rskOkDnWz87IVJfBAaQl0EOUaVoF5czpfQKCYFXaEnGOa5DCcqnqj5tLzmNA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ultra-ft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2018 17:14:10.6652 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51790ec5-be59-444c-5d89-08d64a549833 X-MS-Exchange-CrossTenant-Id: 16b31a13-a8fc-4ef5-912d-fdd1665124c4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=16b31a13-a8fc-4ef5-912d-fdd1665124c4;Ip=[104.156.72.34];Helo=[SRV-CAMTL-EXCH2.Forensictech.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT210 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_8FC5F25FF3EC4744ADFCF20CBA3F44BE016811C1EFSRVCAMTLEXCH2_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Adrien Nayrat wrote: > With 17 million LO, it could eat lot of memory ;) Yes it does. I did several tests and here are my observations. First memory settings are: shared_buffers =3D 3GB work_mem =3D 32Mb maintenance_work_mem =3D 1GB effective_cache_size =3D 9MB bytea_output =3D 'escape' The largest LO is 160KB for the dumped table The largest LO is 20MB for the entire DB (fare from the 1GB) I reduced the shared_buffers to 512Mb and have the same behavior. I increased the pagefile from 8Gb to 16Gb and the dump processed. The total= memory of pg_dump reached nearly 20GB. I killed the dump after 200GB (20 hrs). It pages aggressively and would hav= e last 4 days to dump 800GB. Here is the memory pattern: pg_dump: reading large objects -> Reads pg_largeobject_metadata. Ramp up= gradually from 0 to 4GB during 10mins and jump to nearly 10GB at the end. pg_dump: reading dependency data -> drop to 7GB pg_dump: saving encoding =3D UTF8 pg_dump: saving standard_conforming_strings =3D on -> begin paging a= nd memory total reached 20Gb pg_dump: dumping contents of table "ibisl1.signatures" -> begin writing to= dump file pg_dump: saving large objects -> reading pg_largeobject file nodes and = writing to dump file I performed the same test on a smaller DB (60GB) I dump a single table with LOBs and then the entire DB (3 tables have LOBs)= . - Single 1GB table: 1GB including lobs, 80 000 rows, max LOB size 100KB pg_dump -h localhost -Fc -a -b -t signatures -v > d:\postgresql\sig.dmp - Entire 60GB DB: 3 tables have LOBs, 240 000 LOBs, max LOB size 20MB pg_dump -h localhost -Fc -v > d:\postgresql\db.dmp Both dumps used the same amount of memory (160MB) and dump file sizes are m= ore or less the same 53Gb! We can conclude that the single table dump includes the entire pg_largeobje= ct table, not only the LOBs respective to the table. So why reading the large objects to build a huge structure in memory if all= large objects are going to be dump. There is certainly something to rework. I run another test. I dump the application schema that contains the data. pg_dump -h localhost -Fc -n ibis* -v > d:\postgresql\ibislx.dmp The pg_dump used a few MB, so the memory issue is clearly due to LOB. The relation between the number of large objects and dump memory looks line= ar ~ 650bytes/LOB Small DB: 240 000 lobs =3D 0.160GB Large DB: 28 500 000 lobs =3D 19.5GB Seems a large memory allocation for processing LOB later on. Another area where LOB hurts is the storage. LOB are broken and stored in 2= K pieces. Due to the block header, only three 2k pieces fit in an 8k block wasting 25= % of space (in fact pgstattuple reports ~ 20%). Would you recommend bytea over LOB considering that the max LOB size is wel= l bellow 1GB? Are bytea preferable in terms of support by the community, performance, fea= ture, etc? We choose saving binary data into LOB over bytea because LOB are stored out= of row, and more particularly one table is frequently accessed, but not th= e LOB. However, bytea would be toasted and stored out of row anyway as the binary = data saved is bigger that 2k. Currently the frequently accessed table contains 40 rows per 8k block (avg = row length 200 bytes). Can we just set the toast_tuple_target to 256 bytes for that table to get s= imilar results? Does toasted bytea will be stored in 2K pieces and 25% of space (or less if= toast_tuple_target is changed) be wasted like for LOB? I also presume that when a row (columns other that the bytea) is updated, a= new copy of the bytea will be made in the toast table? So LOB will be more suitable for frequently updated table where the binary = data rarely change. Jean-Marc Lessard Administrateur de base de donn=E9es / Database Administrator Ultra Electronics Forensic Technology Inc. T +1 514 489 4247 x4164 www.ultra-forensictechnology.com --_000_8FC5F25FF3EC4744ADFCF20CBA3F44BE016811C1EFSRVCAMTLEXCH2_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Adrien Nayrat wrote:
> With 17 million LO, it could eat lot of memory ;)
Yes it does.

I did several tests and here are my observations.

First memory settings are:
shared_buffers =3D 3GB
work_mem =3D 32Mb
maintenance_work_mem =3D 1GB
effective_cache_size =3D 9MB
bytea_output =3D 'escape'

The largest LO is 160KB for the dumped table
The largest LO is 20MB for the entire DB (fare from the 1GB)

I reduced the shared_buffers to 512Mb and have the same behavior.
I increased the pagefile from 8Gb to 16Gb and the dump processed. The total= memory of pg_dump reached nearly 20GB.
I killed the dump after 200GB (20 hrs). It pages aggressively and would hav= e last 4 days to dump 800GB.

Here is the memory pattern:
pg_dump: reading large objects    -> Reads pg_largeobject= _metadata. Ramp up gradually from 0 to 4GB during 10mins and jump to nearly= 10GB at the end.
pg_dump: reading dependency data  -> drop to 7GB
pg_dump: saving encoding =3D UTF8
pg_dump: saving standard_conforming_strings =3D on    &= nbsp;   -> begin paging and memory total reached 20Gb
pg_dump: dumping contents of table "ibisl1.signatures"  ->= ; begin writing to dump file
pg_dump: saving large objects     -> reading pg_larg= eobject file nodes and writing to dump file

I performed the same test on a smaller DB (60GB)
I dump a single table with LOBs and then the entire DB (3 tables have LOBs)= .
- Single 1GB table: 1GB including lobs, 80 000 rows, max LOB size 100KB
  pg_dump -h localhost -Fc -a -b -t signatures -v > d:\postgresql\s= ig.dmp
- Entire 60GB DB:   3 tables have LOBs, 240 000 LOBs, max LOB siz= e 20MB
  pg_dump -h localhost -Fc -v > d:\postgresql\db.dmp
Both dumps used the same amount of memory (160MB) and dump file sizes are m= ore or less the same 53Gb!
We can conclude that the single table dump includes the entire pg_largeobje= ct table, not only the LOBs respective to the table.
So why reading the large objects to build a huge structure in memory if all= large objects are going to be dump.
There is certainly something to rework.

I run another test. I dump the application schema that contains the data.   pg_dump -h localhost -Fc -n ibis* -v > d:\postgresql\ibislx.dmp The pg_dump used a few MB, so the memory issue is clearly due to LOB.

The relation between the number of large objects and dump memory looks line= ar ~ 650bytes/LOB
Small DB:    240 000 lobs =3D 0.160GB
Large DB: 28 500 000 lobs =3D 19.5GB
Seems a large memory allocation for processing LOB later on.

Another area where LOB hurts is the storage. LOB are broken and stored in 2= K pieces.
Due to the block header, only three 2k pieces fit in an 8k block wasting 25= % of space (in fact pgstattuple reports ~ 20%).

Would you recommend bytea over LOB considering that the max LOB size is wel= l bellow 1GB?
Are bytea preferable in terms of support by the community, performance, fea= ture, etc?

We choose saving binary data into LOB over bytea because LOB are stored out= of row, and more particularly one table is frequently accessed, but not th= e LOB.
However, bytea would be toasted and stored out of row anyway as the binary = data saved is bigger that 2k.
Currently the frequently accessed table contains 40 rows per 8k block (avg = row length 200 bytes).
Can we just set the toast_tuple_target to 256 bytes for that table to get s= imilar results?

Does toasted bytea will be stored in 2K pieces and 25% of space (or less if= toast_tuple_target is changed) be wasted like for LOB?

I also presume that when a row (columns other that the bytea) is updated, a= new copy of the bytea will be made in the toast table?
So LOB will be more suitable for frequently updated table where the binary = data rarely change.

Jean-Marc Less= ard
Admi= nistrateur de base de donn=E9es / Database Administrator
Ultra Electronics Forensic Technology Inc= .
T +1 514 489 4247 x4164
www.ultra-fo= rensictechnology.com

--_000_8FC5F25FF3EC4744ADFCF20CBA3F44BE016811C1EFSRVCAMTLEXCH2_--