Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 49CA49FB1DC for ; Thu, 11 Jan 2007 06:56:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 56415-06 for ; Thu, 11 Jan 2007 06:56:50 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) by postgresql.org (Postfix) with ESMTP id 591D89FAC76 for ; Thu, 11 Jan 2007 06:56:50 -0400 (AST) Received: by fafnir.androme.com (Postfix, from userid 1003) id 33EA1B990F4; Thu, 11 Jan 2007 11:56:49 +0100 (CET) Message-ID: <45A617F2.6040802@andromeiberica.com> Date: Thu, 11 Jan 2007 11:56:50 +0100 From: Arnau Reply-To: arnaulist@andromeiberica.com User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: PostgreSQL Performance Subject: Does it matters the column order in indexes and constraints creation? 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: 200701/166 X-Sequence-Number: 22767 Hi all, I've got a doubt about how to create an index and a primary key. Lets say I have the following table: CREATE TABLE blacklist ( telephone VARCHAR(15), customer_id INT4 CONSTRAINT fk_blacklist_customerid REFERENCES customers( customer_id ), country_id INT2 CONSTRAINT fk_blacklist_countryid REFERENCES countries( country_id ), CONSTRAINT pk_blacklist_cidcustidtel PRIMARY KEY(country_id, customer_id, telephone) ); The country_id column can have maybe 100 - 250 different values. The customer_id column can have as much several hundred values (less than 1000). The telephone is where all will be different. So my doubt is, in terms of performance makes any difference the order of the primary key fields? The same in the index definition? I have checked the postgresql documentation I haven't been able to find anything about. Thanks -- Arnau