Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0DD15B5DC5D for ; Thu, 22 Sep 2011 10:51:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 40176-10 for ; Thu, 22 Sep 2011 13:51:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 53F4EB5DC09 for ; Thu, 22 Sep 2011 10:51:15 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p8MDpCSc017572; Thu, 22 Sep 2011 09:51:12 -0400 (EDT) To: Robert Haas cc: Greg Stark , Kyotaro HORIGUCHI , pgsql-hackers@postgresql.org Subject: Re: [v9.2] make_greater_string() does not return a string in some cases In-reply-to: References: <20110711.155531.15100243.horiguchi.kyotaro@oss.ntt.co.jp> <20110712.161231.138791411.horiguchi.kyotaro@oss.ntt.co.jp> <20110914.111320.18404009.horiguchi.kyotaro@oss.ntt.co.jp> <6425.1316656167@sss.pgh.pa.us> <8755.1316665444@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Thu, 22 Sep 2011 09:27:21 -0400" Date: Thu, 22 Sep 2011 09:51:12 -0400 Message-ID: <17571.1316699472@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/1125 X-Sequence-Number: 195314 Robert Haas writes: > On Thu, Sep 22, 2011 at 8:59 AM, Greg Stark wrote: >> But the whole problem is that not all the strings with the initial >> substring are in a contiguous block. > If that were true for the sorts of indexes we're using for LIKE > queries, the existing approach wouldn't work either. Right. Since it's not a problem for the sorts of indexes with which we can use LIKE, moving knowledge of LIKE into the btree machinery doesn't buy us a darn thing, except more complexity in a place where we can ill afford it. The essential problem here is "when can you stop scanning, given a pattern with this prefix?", and btree doesn't know any more about that than make_greater_string does; it would in fact have to use make_greater_string or something isomorphic to it. regards, tom lane