Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 6868C9FB781 for ; Thu, 9 Aug 2007 17:01:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 04269-03 for ; Thu, 9 Aug 2007 17:00:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from oxford.xeocode.com (unknown [87.127.95.196]) by postgresql.org (Postfix) with ESMTP id 2F1E89FB772 for ; Thu, 9 Aug 2007 17:00:58 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1IJEBi-0001D2-Ic; Thu, 09 Aug 2007 21:00:54 +0100 From: Gregory Stark To: "Andreas Joseph Krogh" Cc: Subject: Re: PG won't use index on ORDER BY In-Reply-To: <200708092018.44111.andreak@officenet.no> (Andreas Joseph Krogh's message of "Thu, 9 Aug 2007 20:18:43 +0200") Organization: EnterpriseDB References: <200708092018.44111.andreak@officenet.no> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.sql" 756) Date: Thu, 09 Aug 2007 21:00:54 +0100 Message-ID: <87fy2s1nrd.fsf@oxford.xeocode.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/56 X-Sequence-Number: 28994 "Andreas Joseph Krogh" writes: > I create an index: > CREATE INDEX person_lowerfullname_idx ON > person((lower(COALESCE(firstname, '')) || lower(COALESCE(lastname, ''))) > varchar_pattern_ops); Why are you declaring it using the varchar_pattern_ops? The default operator set is the one you want for handling ordering. The pattern_ops operator set is for handling things like x LIKE 'foo%' -- Gregory Stark EnterpriseDB http://www.enterprisedb.com