X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E0787475CBC for ; Tue, 1 Apr 2003 14:08:02 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3A433475AF8 for ; Tue, 1 Apr 2003 14:08:02 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h31J7v2L002297; Tue, 1 Apr 2003 14:07:58 -0500 (EST) To: Robert Treat Cc: Kris , pgsql-admin@postgresql.org Subject: Re: Speed & Memory Management In-reply-to: <1049222487.13853.2110.camel@camel> References: <1049222487.13853.2110.camel@camel> Comments: In-reply-to Robert Treat message dated "01 Apr 2003 13:41:27 -0500" Date: Tue, 01 Apr 2003 14:07:57 -0500 Message-ID: <2296.1049224077@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/10 X-Sequence-Number: 8165 Robert Treat writes: > Unless your application requires a 30 character limit at the logical > level, use text. And if it does, use varchar(30). I will bet a very good lunch that char(30) will be a complete dead loss on *every* measure: speed, disk space, and convenience. char(N) is not really fixed-width in Postgres, because N is measured in characters not bytes (which are not the same thing if you use a multibyte character encoding). Therefore, there are no optimizations that could allow it to outperform varchar(N). When you consider the extra cost of performing the padding step, the extra storage and I/O incurred for all those pad blanks, and the client-side headaches of having to trim the unwanted blanks again, it's just guaranteed to be a loser. The only case in which I could recommend char(N) is where you have application semantics that constrain a field to exactly N characters (postal codes are one common example). If the semantics are "at most N characters", use varchar(N). If you are picking N out of the air, don't bother: use text. regards, tom lane