Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E532FB5DC01 for ; Thu, 22 Sep 2011 11:44:15 -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 04494-05 for ; Thu, 22 Sep 2011 14:44:09 +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 E5228B5DBC4 for ; Thu, 22 Sep 2011 11:44:08 -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 p8MEi5sR018586; Thu, 22 Sep 2011 10:44:06 -0400 (EDT) To: Greg Stark cc: Robert Haas , 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> <17571.1316699472@sss.pgh.pa.us> Comments: In-reply-to Greg Stark message dated "Thu, 22 Sep 2011 15:28:53 +0100" Date: Thu, 22 Sep 2011 10:44:05 -0400 Message-ID: <18585.1316702645@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/1132 X-Sequence-Number: 195321 Greg Stark writes: > On Thu, Sep 22, 2011 at 2:51 PM, Tom Lane wrote: >> 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. > Hm, as long as btree_pattern_ops is the only opclass that behaves this > way that's more or less true. But Robert's right that if btree just > stops when it finds something that doesn't match it doesn't need to > hard code any knowledge of what the "next" value would be. But you've added mechanism (and hence cycles) to btree searches, and *you haven't actually gained anything*. If the feature is restricted to only work for sort orderings in which common-prefix strings are contiguous, then it doesn't do anything we can't do just as well with the existing mechanism. Moreover, you'll still need make_greater_string because of the problem of trying to extract LIKE selectivity estimates from locale-dependent pg_statistic data. regards, tom lane