Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YA1as-0000Ry-7E for pgsql-admin@arkaria.postgresql.org; Sat, 10 Jan 2015 19:21:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YA1ar-0006ja-O3 for pgsql-admin@arkaria.postgresql.org; Sat, 10 Jan 2015 19:21:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YA1ar-0006jU-0c for pgsql-admin@postgresql.org; Sat, 10 Jan 2015 19:21:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YA1an-0005qm-Lt for pgsql-admin@postgresql.org; Sat, 10 Jan 2015 19:21:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t0AJKopt023200; Sat, 10 Jan 2015 14:20:50 -0500 From: Tom Lane To: Albe Laurenz cc: "Ferrell, Denise CTR NSWCDD, Z11 *EXTERN*" , "pgsql-admin@postgresql.org" Subject: Re: PK/FK impacts using text data type In-reply-to: References: <2BC18916DE4BF141AC1EFC55CE2CAE7D614327@NAEANRFKXM01V.nadsusea.nads.navy.mil> Comments: In-reply-to Albe Laurenz message dated "Sat, 10 Jan 2015 19:14:09 +0000" Date: Sat, 10 Jan 2015 14:20:50 -0500 Message-ID: <23199.1420917650@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Albe Laurenz writes: > The only useful thing about varchar is that it imposes a length constraint on a database field. > Values used for indexing have a length limit, so if you change an indexed column to text > somebody could try to insert values that will cause errors because the limit has been exceeded. I'm not particularly buying that argument. If you insert an overlength field value, you will get an error either way; it's just spelled differently. Also, using varchar(N) isn't a particularly efficient way to guard the btree length limit, because N is measured in characters but the btree length limit is in bytes. You'd have to use a very conservatively small N to be absolutely sure you don't get a btree error, and that would result in throwing some errors that actually weren't necessary at all. > Also you application code cannot rely on a certain size limit any more. This is a valid argument, though again only to the extent that you need a size limit measured in characters not bytes. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin