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 1hGlTX-0002SK-90 for pgsql-general@arkaria.postgresql.org; Wed, 17 Apr 2019 14:23:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hGlTV-0000n6-R2 for pgsql-general@arkaria.postgresql.org; Wed, 17 Apr 2019 14:23:45 +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 1hGlTV-0000ml-DX for pgsql-general@lists.postgresql.org; Wed, 17 Apr 2019 14:23:45 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGlTT-00047t-4T for pgsql-general@lists.postgresql.org; Wed, 17 Apr 2019 14:23:44 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 0C23122006; Wed, 17 Apr 2019 10:23:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 17 Apr 2019 10:23:42 -0400 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=fm2; bh=O tUunaQrmKJFbmfXdhXyK8r0JIdLTO5qixbYPZgYhVQ=; b=CZQ8GGmwPQL7RdmH8 VDZ981Qui14X9zKtTbvOhY1y1HySwx8iEMUcRvSUJJfaKigq7VfF/F46tVVoo762 GU4uQiD5DPKNlHanDRZw3gL77IlxRM8inuLuRFDdCiJAuknFk/1YyCQIEYceijHE jQtAtk7jDcvU5aGnebpnQ2Mx4VVcl9H59euPWcnab8cqn0vLsyg971DySjQfGRnr psuw75XNu0AAQ6Fagih0Koq7928tm33H1obmO7gqhLRjRR8MaiMjIHZmk1YNMETU Qg6zUOK8ftX4ma2O+1HshC4/k3Ds0gvSWHw4sSaf/AStnPzbQpqQsvH8MsuIjT/K nrqyA== 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=fm2; bh=OtUunaQrmKJFbmfXdhXyK8r0JIdLTO5qixbYPZgYh VQ=; b=k7TaBHAVi30SdmRAIcuUQeTPLyh7cTsTTm98vfX+oQi1xOBEe7jrhQ6nQ S5QP/XL0JwQMoHGhYzoysh8ADjG3lnOqwVQqXm2GFW3BKMoStYopHZjXpcqC914w oYtmGGqmKhOp8ylAwsJzzeyhkbl0JZGn/yeJ5Wfb3b0yanOP93tILj+iDHnyn/Vh 1gr+3RLYbiSbrBAMoS6g/HXrw/Ubfa4tJS/YqdbWkxUIEHXTs8TkHDxtzQtaaiIh 73/CLJRjyRA2quXNpDqRAypelM/GOA7GmW8ihOaojA1nzgg0gIix9w1aDjh2ySS4 8oZJfOi8swO2kgFjfShtnxAotrtMg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrfeefgdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecukfhppeejuddrvdduvddrudehtddrvddtvdenucfrrghrrghmpehmrghilhhfrhho mheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvg hrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id F1E7A10316; Wed, 17 Apr 2019 10:23:40 -0400 (EDT) Subject: Re: Alter domain type / avoiding table rewrite To: Tim Kane Cc: Ron , pgsql-general@lists.postgresql.org References: <26216.1555423922@sss.pgh.pa.us> <9dc52f4b-94b5-813c-52ba-be22dec1cb93@aklaver.com> <27283.1555425748@sss.pgh.pa.us> <2f57aafd-f034-0f82-5739-614607e4ba0e@aklaver.com> From: Adrian Klaver Message-ID: <8f3295e8-4be9-e40a-f16d-af33eab1176c@aklaver.com> Date: Wed, 17 Apr 2019 07:23:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.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 4/17/19 2:14 AM, Tim Kane wrote: > > > On Tue, 16 Apr 2019 at 18:04, Adrian Klaver > wrote: > > > > Where are you seeing the rewrite in your case? > > > > I’m unfamiliar with ctid (which I now plan to read up on)… I’ve been > looking at /relfilenode____/ > > I’ve observed that relfilenode changes when altering from /old_type > //à varchar(9) /and the operation takes 6 seconds on this data set.____ The table definition and the size of the data set would help with interpreting the below. > > __ > > __ > > PSQL:alpha_db/postgres@[local]=# select relfilenode from pg_class where > relname='test';____ > > relfilenode____ > > -------------____ > > 20669469 ____ > > (1 row)____ > > __ __ > > PSQL:alpha_db/postgres@[local]=# alter table test alter COLUMN exec_id > set data type varchar(9);____ > > ALTER TABLE____ > > Time: 6605.454 ms____ > > > PSQL:alpha_db/postgres@[local]=# select relfilenode from pg_class where > relname='test';____ > > relfilenode____ > > -------------____ > > 20671802 ____ > > (1 row) > > __ __ > > And then the other way… from /varchar(9) //à old_type____/ > > refilenode does not change, and the operation takes 0.3ms____ > > __ __ > > PSQL:alpha_db/postgres@[local]=# alter table test alter COLUMN exec_id > set data type execid_t;____ > > ALTER TABLE____ > > Time: 1.360 ms____ > > PSQL:alpha_db/postgres@[local]=# select relfilenode from pg_class where > relname='test';____ > > relfilenode____ > > -------------____ > > 20671802 ____ > > (1 row)____ > > __ __ > > Time: 0.331 ms____ > > __ > > > Apologies if this formats badly :-/ transcribing between devices not > well suited to email. > > Tim > -- Adrian Klaver adrian.klaver@aklaver.com