Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C9127475D00 for ; Tue, 15 Oct 2002 15:16:57 -0400 (EDT) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by postgresql.org (Postfix) with ESMTP id 123B9475ADE for ; Tue, 15 Oct 2002 15:16:57 -0400 (EDT) Received: (from smtp@localhost) by ll.mit.edu (8.11.3/8.8.8) id g9FJGu803323 for ; Tue, 15 Oct 2002 15:16:56 -0400 (EDT) Received: from sty.llan.ll.mit.edu( ), claiming to be "sty.llan" via SMTP by llpost, id smtpdAAA2JaOAe; Tue Oct 15 15:16:47 2002 Date: Tue, 15 Oct 2002 15:16:47 -0400 From: george young To: pgsql-sql@postgresql.org Subject: int id's helpful for indexing, or just use text names? Message-Id: <20021015151647.65521b8d.gry@ll.mit.edu> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 0.8.5 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/167 X-Sequence-Number: 9884 [linux, postgresql 7.2, 500MHz * 4 xeon cpu's, 1GB ram, hardware raid] My current db has serveral instances of something like: table foos(fooid int2, fooname text, foouser text, foobar int2 references bars(barid)) table bars(barid int2, barname text, barcolor text, primary key(barid) ) etc, where foonames and barnames are known to be, say <20 characters long. And the fooid's and barid's are arbitrary ints only known inside the db. The original reason for these numeric id's, (in another db system long long ago), was to conserve space(now irrelvant with 120G disks) and to make searching and index usage more efficient. Recently, there is increasing call for new apps and even ad-hoc queries.(Thank goodness people are finally interested in this data!) The artificial numeric id's make it a lot harder for naive users to understand the data structure, and sometimes actually requires an extra order of joins. The question is: would I be better off losing all those integer ids and just using the text names as primary indices? Is there much performance lost comparing text strings for every index operation? My db is not huge: longest table has 100k tuples, biggest table has 1k pages, total pg_dump output is 51 Mbytes. Typical activity: ~6000 updates and inserts/day, 30,000 selects/day. -- I cannot think why the whole bed of the ocean is not one solid mass of oysters, so prolific they seem. Ah, I am wandering! Strange how the brain controls the brain! -- Sherlock Holmes in "The Dying Detective"