X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E7E2B3ABF64 for ; Thu, 23 Dec 2004 07:05:08 +0000 (GMT) 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 94640-06 for ; Thu, 23 Dec 2004 07:04:57 +0000 (GMT) Received: from zong.spline.inf.fu-berlin.de (zong.spline.inf.fu-berlin.de [160.45.117.133]) by svr1.postgresql.org (Postfix) with ESMTP id F1CE53ABFAE for ; Thu, 23 Dec 2004 07:04:57 +0000 (GMT) Received: from zong.spline.inf.fu-berlin.de (localhost [127.0.0.1]) by zong.spline.inf.fu-berlin.de (8.13.1/8.13.1) with ESMTP id iBN74t4D030067; Thu, 23 Dec 2004 08:04:55 +0100 Received: (from yann@localhost) by zong.spline.inf.fu-berlin.de (8.13.1/8.13.1/Submit) id iBN74rAi030066; Thu, 23 Dec 2004 08:04:53 +0100 Date: Thu, 23 Dec 2004 08:04:53 +0100 From: Yann Michel To: Litao Wu Cc: pgsql-performance@postgresql.org Subject: Re: Why so much time difference with a same query/plan? Message-ID: <20041223070453.GA30031@zong.spline.inf.fu-berlin.de> References: <20041222200904.94015.qmail@web13124.mail.yahoo.com> <20041222215240.12345.qmail@web13124.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041222215240.12345.qmail@web13124.mail.yahoo.com> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200412/278 X-Sequence-Number: 9653 Hi, On Wed, Dec 22, 2004 at 01:52:40PM -0800, Litao Wu wrote: > Does the order of columns in the index matter since > more than 50% customer_id = 158? > > I think it does not in Oracle. > > Will the performance be better if I change index > xxx_idx to ("domain", customer_id, created)? Well, in Oracle this would of cause matter. Oracle calculates index usage by being able to fill all index's attributes from the left to the right. If any one attribute within is missing Oracle would not test if it is only one attribute missing, or if all other attributes are missing within the query's where clause. Normaly you'd create an index using the most frequently parametrized attributes first, then the second ones and so on. If the usage isn't that different, you would use the most granule attribute in foremost followed by the second and so on. Regards, Yann