Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id C34359FA4B3 for ; Fri, 10 Aug 2007 00:10:58 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 62349-07 for ; Fri, 10 Aug 2007 00:10:54 -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 4AB479FA3BF for ; Fri, 10 Aug 2007 00:10:54 -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 1IJKtj-0001Ym-Q0; Fri, 10 Aug 2007 04:10:47 +0100 From: Gregory Stark To: "Andreas Joseph Krogh" Cc: Subject: Re: PG won't use index on ORDER BY In-Reply-To: <200708092238.46284.andreak@officenet.no> (Andreas Joseph Krogh's message of "Thu, 9 Aug 2007 22:38:46 +0200") Organization: EnterpriseDB References: <200708092018.44111.andreak@officenet.no> <87fy2s1nrd.fsf@oxford.xeocode.com> <200708092238.46284.andreak@officenet.no> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX" 30667) Date: Fri, 10 Aug 2007 04:10:47 +0100 Message-ID: <87abt0rsnc.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/63 X-Sequence-Number: 29001 "Andreas Joseph Krogh" writes: > Ooops, just fugured that out. But - it still doesn't use the index if I remove > the "varchar_pattern_ops". I solved it by adding a function: Hm, well it does for me, you would have to post your explain analyze to see what's going on. > Another question then: Why doesn't "varchar_pattern_ops" handle ordering? This > means I need 2 indexes on the columns I want to match with LIKE and ORDER BY. > Just doesn't seem right to need 2 "similar" indexes... If you initd in the C locale you only need one index. In other locales the collation order and the pattern order are different. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com