Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTB8m-0000XR-8D for pgsql-general@arkaria.postgresql.org; Thu, 06 Jul 2017 18:04:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dTB8k-0002Gk-OA for pgsql-general@arkaria.postgresql.org; Thu, 06 Jul 2017 18:04:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dTB8k-0002GX-1c for pgsql-general@postgresql.org; Thu, 06 Jul 2017 18:04:34 +0000 Received: from mail-it0-x230.google.com ([2607:f8b0:4001:c0b::230]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dTB8a-0003nK-U3 for pgsql-general@postgresql.org; Thu, 06 Jul 2017 18:04:33 +0000 Received: by mail-it0-x230.google.com with SMTP id m68so10185900ith.1 for ; Thu, 06 Jul 2017 11:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=Zsq8NOF5SQbvAEkwNwfvXvE0JmYcTYE8iG4Dt0AuRtM=; b=UivEl/KzUQrN809vMTEQXJPT6mhdd+l9XOauhol9WSnAOpw5gA9gOt6cIoEhctJFBx lnAfPPH9Hc1dtEX9LMUhVu12zBurrVqkqW3Fgl1j3fOCBD3nhOMXw6E0CK4snpqeXmXE 58oWZFPtU1xZO/8w3YyrQ/ECzYnM6K8VjIfe4QgeiCG+YC4oPNqCrXv1uxa3ZN9YM/+u 5ggID83ZgOhXqo7E9qXDpsgzeXK7rGs3ysiNAkXXLj2AvUr2FVN0UeNX3cGJQz9XNAMq uG8du9gw8VOUAcRunOKbKU59lPFMg759Vgm4dSLUmhs8sF+X+2mAdDLa/gYvREMBEp67 6Jjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=Zsq8NOF5SQbvAEkwNwfvXvE0JmYcTYE8iG4Dt0AuRtM=; b=WeFImomm/ZcjQGFut1pbcAiEKoi4UbSwPY7phNlGyxjjpAYZWwTizB7HxE2wkpUsA1 RujmE8OpGqDzjXE75T+H7+ydzpK9HRg99x+kDnD0RQklXGdjg52zCw9qKsnZUSa52hOz iUe+xAafXgiYmYBeTnrdAGdYv5zsLuzxM47CfIrJVtUdvxYh27A9ZdHj42M0WBtsfyRD XDF1Y0AWAphPXmcaThA1X2PrE6YO+zl6vng3G3SKinUPAE3LByHPUbgX16uAMtzK3b5N VZWjj7gDJF4Hj3rwXd6XvD5+ThOIsw4Sk7TVyimUPdJLaB9e3E6LGypZJC7me/xNGt23 oF4Q== X-Gm-Message-State: AKS2vOxw71b/Gd1bV0CGZlctWFCWcW1z3oVFTLBtJ51XDZym2tva6o0+ SUDwkNU6ZM2sXtYXGcbHDg== X-Received: by 10.107.130.75 with SMTP id e72mr48794844iod.31.1499364261403; Thu, 06 Jul 2017 11:04:21 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id m15sm485221iti.19.2017.07.06.11.04.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jul 2017 11:04:21 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 2D288801571; Thu, 6 Jul 2017 13:04:20 -0500 (CDT) Date: Thu, 6 Jul 2017 13:04:20 -0500 From: Justin Pryzby To: pgsql-general@postgresql.org Subject: huge RAM use in multi-command ALTER of table heirarchy Message-ID: <20170706180420.GH30252@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org I've seen this before while doing SET STATISTICS on a larger number of columns using xargs, but just came up while doing ADD of a large number of columns. Seems to be roughly linear in number of children but superlinear WRT columns. I think having to do with catalog update / cache invalidation with many ALTERs*children*columns? 32 cols and 2 children => 12MB 256 cols and 11 children => 74MB 256 cols and 111 children => 582MB 512 cols and 11 children => 229MB (in our "huge" case, there were ~1600 columns and maybe even more children) I was testing with this command PGHOST=/tmp PGPORT=9999 sh -ec 'for maxcols in 512 ; do ~/src/postgresql.install/bin/postgres -D ~/src/postgres.dat -c port=9999 & sleep 4; cols=$(for d in `seq 1 $maxcols`; do echo "ADD c$d int,"; done |xargs); PGOPTIONS="-c client_min_messages=warning" psql postgres -qc "DROP TABLE t CASCADE" || [ $? -eq 1 ]; psql postgres -qc "CREATE TABLE t()"; for c in `seq 1 11`; do psql postgres -qc "CREATE TABLE c$c() INHERITS(t)"; done; for d in `seq 1 $maxcols`; do echo "ALTER TABLE t ADD c$d int;"; done |PGOPTIONS="-c client_min_messages=DEBUG3 -c log_statement_stats=on" psql postgres -c "ALTER TABLE t ${cols%,}" 2>/tmp/pg.err2; ~/src/postgresql.install/bin/pg_ctl -swD ~/src/postgres.dat stop; done' ..and log_statment_stats with a variation on the getrusage patch here https://www.postgresql.org/message-id/20170615145824.GC15684%40telsasoft.com Justin -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general