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 1hGRVz-0004Ku-7E for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2019 17:05:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hGRVx-0000jF-QL for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2019 17:04:57 +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 1hGRVv-0000j8-LC for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2019 17:04:57 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGRVr-0001I1-OQ for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2019 17:04:54 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C197B234D4; Tue, 16 Apr 2019 13:04:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 16 Apr 2019 13:04:50 -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=d 7zmXbwK5mUQdhlkv4o/n27Bnn27i2GIoarM0RSZnz8=; b=quZlAeDm8VeCqbe8a /0O/LTMx5GKR6MU3+RN8eeZ69LDF5E7Z0M6TzMHWmsIfbOsg3zGGcwjNHFtcfLdL xcapV0DehgEJu3/8PxbjfFgd/scSL5Vra1J2kR1W68hU4zAECtPcsxsry17ErmMb thYp9evkwUPhiFoVgyfizuob05zG+OzdVhSDelZdu3+YbHhwndqvrd3SoRAZMtcy JWjSmdwAPX/E8nForjO9OfMikNMMd8bxwEz9ljbf/qbttkF/5vPnnvzcRZM2JT0X vqp4ieStrZ8yoqjKpZYmfn6mVg9S580iui4oYtdU3vZsByEGDHChfHVhtTe1b57z lvh8w== 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=d7zmXbwK5mUQdhlkv4o/n27Bnn27i2GIoarM0RSZn z8=; b=TyJ+mingdl3TovKigXG0To1KgFIh3OjDjp3TBbySCKeL9qtzjlkqSpgHz IzhW8rXjrhaAxUdzss4fxQW+8tE2aQuzwl2IhnsbG4h4Cj5u+Mor6vjHGF/LMl98 GUXlOlfu8GndoisLa8unMiFU/rRyO2aac0v5OUFEEDnQM6oWwuwvdEdzEOv2Q8VE NJZLEMGlNcwZofiwaEze5BKITTyRT+QyLN14gC7j3dbPWHBymO2wEzJ07JbUJ2Xp uMdNJgWRzuDO+ZDSF+In2jrS1TUOSSrobktngYpqafEOKJR4qqBd3s+c6n5KQMZl OngKT2I6xY5bBqAtgFUe6TTh8RB9A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrfedugddutdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjeegrdelgedrjeefrddvvddvnecurfgrrhgrmhepmhgrihhlfhhrohhm pegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrh fuihiivgeptd X-ME-Proxy: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id AC6E6103D0; Tue, 16 Apr 2019 13:04:49 -0400 (EDT) Subject: Re: Alter domain type / avoiding table rewrite To: Tim Kane , Ron Cc: 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> From: Adrian Klaver Message-ID: <2f57aafd-f034-0f82-5739-614607e4ba0e@aklaver.com> Date: Tue, 16 Apr 2019 10:04:48 -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: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/16/19 9:18 AM, Tim Kane wrote: > Thanks everyone.. > > It seems that the first step: > > old_type --> varchar(9) > > still requires a table rewrite, while the reverse direction does not. Hmm: CREATE DOMAIN old_type AS varchar(9); create table rewrite_test (id integer, fld_1 old_type); insert into rewrite_test values (1, '123456789'), (2, '123'); select ctid from rewrite_test; ctid ------- (0,1) (0,2) alter table rewrite_test alter COLUMN fld_1 set data type varchar(9); select ctid from rewrite_test; ctid ------- (0,1) (0,2) update rewrite_test set fld_1 = '1' where id =2; select ctid from rewrite_test; ctid ------- (0,1) (0,3) Where are you seeing the rewrite in your case? > > > I'm curious about the performance implication of domain types, i expect > that cost is only at insert/update time? I guess we've been wearing that > cost up until now. > > Adrian is correct - the intention for the DOMAIN with CHECK approach was > to allow flexibility moving forward, as the data set is particularly > large... > > I'm now thinking that since promotion to a larger size is a non-issue, > and domain type seems to be not quite the panacea I hoped, then the use > of varchar(n) is perhaps not so terrible! > > Thanks for the advice/suggestions/discussion :) > > -- Adrian Klaver adrian.klaver@aklaver.com