X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E637A529C7 for ; Sat, 20 Aug 2005 10:08:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24690-05 for ; Sat, 20 Aug 2005 13:08:14 +0000 (GMT) Received: from linuxworld.com.au (unknown [203.34.46.50]) by svr1.postgresql.org (Postfix) with ESMTP id BE0ED5299B for ; Sat, 20 Aug 2005 10:08:10 -0300 (ADT) Received: from linuxworld.com.au (IDENT:swm@localhost.localdomain [127.0.0.1]) by linuxworld.com.au (8.13.2/8.13.2) with ESMTP id j7KD8ES8004254; Sat, 20 Aug 2005 23:08:14 +1000 Received: from localhost (swm@localhost) by linuxworld.com.au (8.13.2/8.13.2/Submit) with ESMTP id j7KD8D3q004251; Sat, 20 Aug 2005 23:08:13 +1000 X-Authentication-Warning: linuxworld.com.au: swm owned process doing -bs Date: Sat, 20 Aug 2005 23:08:13 +1000 (EST) From: Gavin Sherry X-X-Sender: swm@linuxworld.com.au To: ohp@pyrenet.fr Cc: pgsql-performance@postgresql.org Subject: Re: index as large as table In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 required=5 tests=[AWL=0.002] X-Spam-Level: X-Archive-Number: 200508/293 X-Sequence-Number: 14040 On Sat, 20 Aug 2005 ohp@pyrenet.fr wrote: > Hi, > > While testing 8.1dev I came to this: > > CREATE TABLE t ( > a int, > b int > PRIMARY KEY (a,b)); > > In that case, the index is as big as the table. Right. Think about it: the index must store a, b, a reference to the data in the table itself and index meta data. If an index is defined across all columns of the table, it must be bigger than the table itself. (In PostgreSQL, when the table is small, the index will be smaller still. This is because of each entry in the table itself has meta data. But the amount of data per row of a table remains constant, whereas, the amount of metadata in an index grows.) > My question is is it worthwhile to have such index peformance wise. > I understand I'd loose uniqness buthas such an index any chance to be used > against seq scan. Of course. The idea is that, generally speaking, you're only interested in a small portion of the data stored in the table. Indexes store extra data so that they can locate the portion you're interested in faster. Gavin