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 1iovyV-0004lA-L9 for pgsql-general@arkaria.postgresql.org; Tue, 07 Jan 2020 21:01:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iovyU-0005BE-4E for pgsql-general@arkaria.postgresql.org; Tue, 07 Jan 2020 21:01:14 +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 1iovyS-0005B7-5t for pgsql-general@lists.postgresql.org; Tue, 07 Jan 2020 21:01:13 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iovyO-0004JC-Qa for pgsql-general@lists.postgresql.org; Tue, 07 Jan 2020 21:01:10 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id D8E9461D; Tue, 7 Jan 2020 16:01:06 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 07 Jan 2020 16:01:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=B HltDc9V8P7BgLL+4Y0j1jZE6HSgiNNUMY521VoExw0=; b=a8lBAXNNIUKeF+LWq LPk5RunV6rHf53ftpF+ukN+J3yuf7l0yqYei3XJ9+Vj1Yc0JtyAkv/ILaIg6YtVL iXH+KkdyZcNFMQf4qTYGGLoxfrPALNBu2HxEOXZQZYncYgYm0NnxKrFOivG3+g2N du/d3EnOx2UcNeBhaK+ucAwH0YHjBW/LhSiZ/UC3InhuV4nzf5w+y1+y6G3t86G7 Q55cODgUQB+NpzPIKxbr5GxH8QKsl/beGWEmephsEtrM+dMe7KzUodSfc+IKmYvw IWJQxbFXAk9F26pKWx2bc5nCd4zH3fj/JjlRcHvsJL1Yh0L50gyAktb3B21LxpxP 8JBBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=BHltDc9V8P7BgLL+4Y0j1jZE6HSgiNNUMY521VoEx w0=; b=Eig3wike/TWYKmPp3hXneFLG/MshW68LRyK+MhGUUNMySvOBp88j+2KrG C1yYn7+fGuXxRuR/bDPahYGOujbX9s9c3BCbMc1HnDcff99Q9YBZfrkvNHSOhBqT B+Hg9PsQpLPsnuy7+pOHx7GAAjAwkl2CLkRgvZ/PReaZJTwpBzZi/G+7STrC4uYf gIZs2qlBlLBvwArdZH6vs57Do6LO28N+7ToyTJ0ig+2Nn95t91NyNCuM5pP0BABY 7aPx3pizUG+q7g9De9NhGpYSQGlHVxefDVyrDgTWkivE+GUtyKvVC3k2KRMDnuKW lZk4q55YGE21AR33wQjqJa9phLv3w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdehiedgvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduvdelrdduleefnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id E333D80064; Tue, 7 Jan 2020 16:01:04 -0500 (EST) Subject: Re: UPDATE many records To: Israel Brewster , Mark Zellers Cc: "pgsql-general@lists.postgresql.org" References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu> From: Adrian Klaver Message-ID: <4c7f993f-f233-dfb6-29b8-98fdf24ec033@aklaver.com> Date: Tue, 7 Jan 2020 13:01:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/7/20 12:47 PM, Israel Brewster wrote: > One potential issue I just thought of with this approach: disk space. > Will I be doubling the amount of space used while both tables exist? If > so, that would prevent this from working - I don’t have that much space > available at the moment. It will definitely increase the disk space by at least the data in the new table. How much relative to the old table is going to depend on how aggressive the AUTOVACUUM/VACUUM is. A suggestion for an alternative approach: 1) Create a table: create table change_table(id int, changed_fld some_type) where is is the PK from the existing table. 2) Run your conversion function against existing table with change to have it put new field value in change_table keyed to id/PK. Probably do this in batches. 3) Once all the values have been updated, do an UPDATE set changed_field = changed_fld from change_table where existing_table.pk = change_table.id; > --- > Israel Brewster > Software Engineer > Alaska Volcano Observatory > Geophysical Institute - UAF > 2156 Koyukuk Drive > Fairbanks AK 99775-7320 > Work: 907-474-5172 > cell:  907-328-9145 -- Adrian Klaver adrian.klaver@aklaver.com