Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 7AF4EB5DC5F for ; Thu, 22 Sep 2011 11:36:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 38773-08 for ; Thu, 22 Sep 2011 14:36:31 +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 CB3CDB5DC5D for ; Thu, 22 Sep 2011 11:36:30 -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 p8MEaSCS018435; Thu, 22 Sep 2011 10:36:28 -0400 (EDT) To: Robert Haas cc: 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 08:49:57 -0400" Date: Thu, 22 Sep 2011 10:36:28 -0400 Message-ID: <18434.1316702188@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/1131 X-Sequence-Number: 195320 Robert Haas writes: > On Thu, Sep 22, 2011 at 12:24 AM, Tom Lane wrote: >> Now, having said that, I'm starting to wonder again why it's worth our >> trouble to fool with encoding-specific incrementers.  The exactness of >> the estimates seems unlikely to be improved very much by doing this. > Well, so the problem is that the frequency with which the algorithm > fails altogether seems to be disturbingly high for certain kinds of > characters. I agree it might not be that important to get the > absolutely best next string, but it does seem important not to fail > outright. Kyotaro Horiguchi gives the example of UTF-8 characters > ending with 0xbf. [ thinks for a bit ... ] Yeah, it's certainly true that such a character might be relatively small in the overall sort order. The assumption underlying what we're doing now is that dropping the last character and incrementing the next-to-last one instead isn't terribly catastrophic from an estimation accuracy standpoint. I can see that there are cases where that would fail to be true, but I'm not exactly convinced that they're worse than all the other cases where we'll get a poor estimate. Anyway, I won't stand in the way of the patch as long as it's modified to limit the number of values considered for any one character position to something reasonably small. regards, tom lane