Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 1BDEF4774FA for ; Fri, 28 Jun 2002 17:25:53 -0400 (EDT) Mailbox-Line: From tgl@sss.pgh.pa.us Fri Jun 28 17:25:53 2002 Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 974BF4774EC for ; Fri, 28 Jun 2002 17:05:32 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g5SL5XD09679; Fri, 28 Jun 2002 17:05:33 -0400 (EDT) To: Ray Ontko Cc: pgsql-admin@postgresql.org Subject: Re: Are statistics gathered on function indexes? In-reply-to: <9555.1025297447@sss.pgh.pa.us> References: <200206282042.PAA07634@shire.ontko.com> <9555.1025297447@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 28 Jun 2002 16:50:47 -0400" Date: Fri, 28 Jun 2002 17:05:33 -0400 Message-ID: <9676.1025298333@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-5.4 required=5.0 tests=IN_REP_TO,X_NOT_PRESENT,SUBJ_ENDS_IN_Q_MARK version=2.30 X-Spam-Level: X-Archive-Number: 200206/248 X-Sequence-Number: 4681 > The stats themselves look fine to me; I think there must be a > mathematical error in what selfuncs.c is doing with them. > Still looking to find it... Oh, I see it: range selectivity double-excludes NULLs. See the comment for clauselist_selectivity in src/backend/optimizer/path/clausesel.c. The individual estimates for the two component comparison operators each exclude nulls, and when we merge them together we get the wrong answer. Good catch! (Though I'm surprised no one noticed this before; with a larger null population the error would be much more obvious.) I'm running out of time today but will look into a fix later. regards, tom lane