Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 526CD2E0032 for ; Wed, 21 May 2008 04:33:46 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 98934-02 for ; Wed, 21 May 2008 04:33:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ipmail01.adl6.internode.on.net (ipmail01.adl6.internode.on.net [203.16.214.146]) by developer.postgresql.org (Postfix) with ESMTP id 057DD2E002C for ; Wed, 21 May 2008 04:33:39 -0300 (ADT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArEFAFZsM0jLevdH/2dsb2JhbAAsgSmuOg X-IronPort-AV: E=Sophos;i="4.27,519,1204464600"; d="scan'208";a="107386981" Received: from ppp247-71.static.internode.on.net (HELO DevBox.local) ([203.122.247.71]) by ipmail01.adl6.internode.on.net with ESMTP; 21 May 2008 17:03:35 +0930 Message-ID: <4833D04E.8060403@Sheeky.Biz> Date: Wed, 21 May 2008 17:03:34 +0930 From: Shane Ambler User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: Craig Ringer CC: Robins Tharakan , pgsql-performance@postgresql.org Subject: Re: Varchar pkey instead of integer References: <36af4bed0805202240v5fbdd6bcv75643a6488cd1daf@mail.gmail.com> <4833C285.5000603@postnewspapers.com.au> In-Reply-To: <4833C285.5000603@postnewspapers.com.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/282 X-Sequence-Number: 30250 Craig Ringer wrote: >> p.s.: I am not as much concerned with the size that it'd take on the data >> tables, as much as the fact that the select / insert performances >> shouldn't >> suffer. However, if that increase in size (per data record) may make a >> considerable impact on the performance, I would certainly want to take >> that >> into account during design phase. > > I suspect it's just another tradeoff - table size increase (and thus > scan performance cost) from storing the text vs avoiding the need to > access the lookup table for most operations. > Size can affect performance as much as anything else. In your case of limited rows it will make little difference, though the larger table with millions of rows will have this key entered for each row and be indexed as the foreign key. The real question is how you want to use the column, if you wish to query for rows of a certain currency then you will notice the difference. You could use a smallint of 2 bytes each (or a varchar(1) with an int value instead of a real char) or an integer of 4 bytes, compared to your varchar(10) Data size on the column could be less than half of the size of the varchar(10) so there will be less disk reads (the biggest slow down) and smaller indexes which can increase chances of caching. Without storage overheads each million rows will have 10*1000000=10M bytes of data compared to 4*1000000=4M bytes - you can see that the chance of caching and the time to read off disk will come into effect each time you reference that column. -- Shane Ambler pgSQL (at) Sheeky (dot) Biz Get Sheeky @ http://Sheeky.Biz