X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 0308F9DC981 for ; Mon, 9 Jan 2006 22:54:42 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78663-04 for ; Mon, 9 Jan 2006 22:54:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id D015E9DC93B for ; Mon, 9 Jan 2006 22:54:40 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k0A2siWB024373; Mon, 9 Jan 2006 21:54:44 -0500 (EST) To: Andrea Arcangeli cc: pgsql-performance@postgresql.org Subject: Re: NOT LIKE much faster than LIKE? In-reply-to: <20060110022303.GA20168@opteron.random> References: <20060110014447.GB18474@opteron.random> <24021.1136858688@sss.pgh.pa.us> <20060110022303.GA20168@opteron.random> Comments: In-reply-to Andrea Arcangeli message dated "Tue, 10 Jan 2006 03:23:03 +0100" Date: Mon, 09 Jan 2006 21:54:44 -0500 Message-ID: <24372.1136861684@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.078 required=5 tests=[AWL=0.078] X-Spam-Score: 0.078 X-Spam-Level: X-Archive-Number: 200601/77 X-Sequence-Number: 16555 Andrea Arcangeli writes: > If you don't know the data, I think it's a bug that LIKE is assumed to > have a selectivity above 50%. Extrapolating from the observation that the heuristics don't work well on your data to the conclusion that they don't work for anybody is not good logic. Replacing that code with a flat 50% is not going to happen (or if it does, I'll be sure to send the mob of unhappy users waving torches and pitchforks to your door not mine ;-)). I did just think of something we could improve though. The pattern selectivity code doesn't make any use of the statistics about "most common values". For a constant pattern, we could actually apply the pattern test with each common value and derive answers that are exact for the portion of the population represented by the most-common-values list. If the MCV list covers a large fraction of the population then this would be a big leg up in accuracy. Dunno if that applies to your particular case or not, but it seems worth doing ... regards, tom lane