X-Original-To: pgsql-bugs-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D00559FA66C for ; Wed, 5 Jul 2006 05:34:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 71582-05 for ; Wed, 5 Jul 2006 05:34:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pancernik.batory.org.pl (pancernik.batory.org.pl [62.89.72.210]) by postgresql.org (Postfix) with ESMTP id 79FF29FA0EC for ; Wed, 5 Jul 2006 05:34:02 -0300 (ADT) Received: from pancernik.batory.org.pl (localhost.localdomain [127.0.0.1]) by pancernik.batory.org.pl (8.13.6/8.13.6) with ESMTP id k658Y0Oa000743; Wed, 5 Jul 2006 10:34:00 +0200 Received: (from tometzky@localhost) by pancernik.batory.org.pl (8.13.6/8.13.6/Submit) id k658XxEw000742; Wed, 5 Jul 2006 10:33:59 +0200 Date: Wed, 5 Jul 2006 10:33:59 +0200 From: Tomasz Ostrowski To: Tom Lane Cc: pgsql-bugs@postgresql.org Subject: Re: query very slow when enable_seqscan=on Message-ID: <20060705083358.GA570@batory.org.pl> References: <20060703203105.GA2801@batory.org.pl> <7353.1151967946@sss.pgh.pa.us> <20060704083733.GA20102@batory.org.pl> <13853.1152021389@sss.pgh.pa.us> <20060704144406.GA21511@batory.org.pl> <25494.1152036954@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25494.1152036954@sss.pgh.pa.us> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/25 X-Sequence-Number: 15370 On Tue, 04 Jul 2006, Tom Lane wrote: > Tomasz Ostrowski writes: > > So why estimate regex expressions if there is no estimation possible? > > Let's set this estimate to be pessimistic (match everything or > > everything not null) and it will choose better plans. > > Better plans for this specific example, worse plans for other cases. > Life is not that simple. It isn't. This worse plans will be choosen only when pattern/regex matching is used and will be, say, 2 times worse. What I'm trying to point out is that some people use regular expressions for filtering rows. When the program is written it is often impossible to know what data will be put into it. And when a program is unexpectedly 2000 times slower than normal it is much worse than if it is 2 times slower, but predictable. I know Postgres uses probabilistic approach so there's always a probability that the planner chooses very wrong. But this probability is so small that it can be ignored. With pattern/regex matching it is not. Regards Tometzky -- ...although Eating Honey was a very good thing to do, there was a moment just before you began to eat it which was better than when you were... Winnie the Pooh