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 1hGPhQ-000843-5n for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2019 15:08:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hGPhO-0002dN-Rq for pgsql-general@arkaria.postgresql.org; Tue, 16 Apr 2019 15:08:38 +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 1hGPhO-0002d9-EN for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2019 15:08:38 +0000 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hGPhL-00071z-US for pgsql-general@lists.postgresql.org; Tue, 16 Apr 2019 15:08:37 +0000 Received: by mail-ot1-x342.google.com with SMTP id o74so17871719ota.3 for ; Tue, 16 Apr 2019 08:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=vDyGhog0ZPcIm84JKeKVGsP1guB+CHHGkdxL//OTTw4=; b=tX3W6TlWVL4ZBTD47qeLxhTuvddaJesZ5PEdeLb2MzIn1Lu6Tbq+vxQHGaWecy2IAh D+3trOwLqn5isOcWkoFSQTEq3NkxLRlYH+8T4AWNGCJv/b05wyVJJM8DSDU7182PJleV QN3ZWocw6+tM2Gls4hqSBhOB2OgrJal5WKO9aVpsEap97uDxftyK7qQJNCSqszHkvHA/ B8YZ476jCxYPOq3kGYGF5j/x00tvqj/6naAKEbNUPAcR3NOo4POgT/e5/RZuPK7zexL9 GvRW/y4jsQfimoK3qkbjg329rVovuMtMOBQw5zCZO9dsmqcWXTHsw+nSKy8jOSE5uQyq VWXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=vDyGhog0ZPcIm84JKeKVGsP1guB+CHHGkdxL//OTTw4=; b=IC94/ut4b5ig+7jWXjZctAwrVodmZ+PYo9rwY+9XJR3CDIY3wxoZjba5YWxfJnw+mf BT8iIktKCvXLMbO/dv50VGSOIl/iuB8YNRnGe1+jbuuAvX/zsePcaXbFdl+cMB1QiwoK c+eMFEX1KY5fX+Uc8FTwidO1tjQdk3BmJYl8HmID1zlZ+qvyRWjj8mWTU13K+BGf/kgp Y1YTGT8tLcAN3F547dKiIrjMshUTknDYKFbDFf3R4gSqn8HvhfXoeIDed8Dyvb/DPK7g lXaogNsfAuBdslKF/Oi7FX5g7pxPIrXRuTIrdGwfl7VSeIBqCGkG+iIXMuLdaq/qE5vH ROuA== X-Gm-Message-State: APjAAAU1Gc5qTdCQd5idDdwvZhaeY9fbW9XU7so7hSh3n/gM6nZMYe0g sbFDEvLXmccLz3ME+vUx82vkkMBFtJ0= X-Google-Smtp-Source: APXvYqyTc5RRpIBCrXh1rOpuOScJRmhZjhQ73a1VHQeJyQvFisaUgQHmPqfwVEtoSZ4i2sY3pgV1nA== X-Received: by 2002:a9d:27e3:: with SMTP id c90mr51699665otb.214.1555427314361; Tue, 16 Apr 2019 08:08:34 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id 189sm21160135oii.58.2019.04.16.08.08.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Apr 2019 08:08:33 -0700 (PDT) Subject: Re: Alter domain type / avoiding table rewrite To: 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: Ron Message-ID: Date: Tue, 16 Apr 2019 10:08:32 -0500 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: <27283.1555425748@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/16/19 9:42 AM, Tom Lane wrote: > Adrian Klaver writes: >> I suspect the OP wants the type to text with a CHECK constraint to allow >> for increasing the length of field values in the future by just changing >> the CHECK setting. If that is the case would changing the type to text >> and then adding a CHECK NOT VALID work without too much pain? > I don't think we really support NOT VALID on domain constraints do we? > > In any case, the point remains that domains are pretty inefficient > compared to native types like varchar(12); partly because the system > can't reason very well about arbitrary check constraints as compared > to simple length constraints, and partly because the whole feature > just isn't implemented very completely or efficiently. So you'll be > paying *a lot* for some hypothetical future savings. Domains are great for maintaining data type consistency across many tables/columns.  Normalization can obviate much of that need, and denormalization increases it. > (Having said that, you're already paying a fair chunk of that > overhead with your existing domain type, so maybe it's not bothering > you. But I'm worried that going from domain-without-check-constraint > to domain-with-check-constraint is going to bite you.) > > regards, tom lane > > -- Angular momentum makes the world go 'round.