Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2F076B5D944 for ; Wed, 3 Aug 2011 22:58:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 61847-02 for ; Thu, 4 Aug 2011 01:58:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from images.kandalaya.org (etc.kandalaya.org [83.143.86.98]) by mail.postgresql.org (Postfix) with ESMTP id 552E7B5D80A for ; Wed, 3 Aug 2011 22:58:44 -0300 (ADT) Received: from mail.linux-delhi.org (ABTS-North-Dynamic-089.131.163.122.airtelbroadband.in [122.163.131.89] (may be forged)) by images.kandalaya.org (8.14.3/8.14.3/Debian-9) with ESMTP id p741wc9n009372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Aug 2011 07:28:42 +0530 Received: from mail.linux-delhi.org (raju@localhost [127.0.0.1]) by mail.linux-delhi.org (8.14.4/8.14.4/Debian-2) with ESMTP id p741wRQc006784 for ; Thu, 4 Aug 2011 07:28:28 +0530 From: "Raj Mathur (=?utf-8?b?4KSw4KS+4KSc?= =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=)" Reply-To: raju@linux-delhi.org Organization: Kandalaya To: pgsql-sql@postgresql.org Subject: Re: Generic design: char vs varchar primary keys Date: Thu, 4 Aug 2011 07:28:25 +0530 User-Agent: KMail/1.13.7 (Linux/2.6.38-2-686-bigmem; KDE/4.6.3; i686; ; ) References: <201108032040.17628.raju@linux-delhi.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201108040728.26315.raju@linux-delhi.org> X-Virus-Scanned: clamav-milter 0.95.2 at images.kandalaya.org X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201108/13 X-Sequence-Number: 35681 On Thursday 04 Aug 2011, Josh Kupershmidt wrote: > 2011/8/3 Raj Mathur (=E0=A4=B0=E0=A4=BE=E0=A4=9C =E0=A4=AE=E0=A4=BE=E0=A4= =A5=E0=A5=81=E0=A4=B0) : > > Can you point me to any pages that explain the difference between > > using, say CHAR(8) vs VARCHAR(8) as the primary key for a table? > > Is there any impact on the database in terms of: > >=20 > > - Speed of indexed retrieval > > - Speed of join from a referencing table > > - Storage (I presume VARHAR(8) would have a slight edge, in > > general) - Any other issue > I suspect the tiny size differences between char(8) and varchar(8) > are going to be negligible. In fact, this post talks precisely about > this concern, and more: > =20 > http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varc > har-vs-text/ >=20 > Personally I'd be most worried about the different semantics of the > types (i.e. treatment of trailing spaces), and perhaps the ease of > expanding the length constraint in the future. Thanks, that's useful for benchmarking the various textual data types. =20 Anything specific about using CHAR vs VARCHAR for primary keys that are=20 going to be referenced from multiple tables that comes to mind? Regards, =2D- Raj =2D-=20 Raj Mathur raju@kandalaya.org http://kandalaya.org/ GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F PsyTrance & Chill: http://schizoid.in/ || It is the mind that moves