X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 84733D7C46 for ; Sat, 27 Aug 2005 12:40:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61700-02 for ; Sat, 27 Aug 2005 15:40:46 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A3B65D795F for ; Sat, 27 Aug 2005 12:40:45 -0300 (ADT) 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 j7RFeg2O001639; Sat, 27 Aug 2005 11:40:42 -0400 (EDT) To: "Steinar H. Gunderson" Cc: pgsql-performance@postgresql.org Subject: Re: Weird performance drop after VACUUM In-reply-to: <20050827152603.GF17097@uio.no> References: <1125093859.9329.30.camel@localhost.localdomain> <26745.1125099111@sss.pgh.pa.us> <20050827101945.GA18155@uio.no> <1404.1125155101@sss.pgh.pa.us> <20050827152603.GF17097@uio.no> Comments: In-reply-to "Steinar H. Gunderson" message dated "Sat, 27 Aug 2005 17:26:03 +0200" Date: Sat, 27 Aug 2005 11:40:42 -0400 Message-ID: <1638.1125157242@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/480 X-Sequence-Number: 14227 "Steinar H. Gunderson" writes: > On Sat, Aug 27, 2005 at 11:05:01AM -0400, Tom Lane wrote: >> It could, but it doesn't really have enough information. We don't >> currently have any model that some operators are more expensive than >> others. IIRC the only sort of reordering the current code will do >> in a filter condition list is to push clauses involving sub-SELECTs >> to the end. > I was more thinking along the lines of reordering "a AND/OR b" to "b AND/OR > a" if b has lower selectivity than a. Yeah, but if b is considerably more expensive to evaluate than a, that could still be a net loss. To do it correctly you really need to trade off cost of evaluation against selectivity, and the planner currently only knows something about the latter (and all too often, not enough :-(). I'd like to do this someday, but until we get some cost info in there I think it'd be a mistake to do much re-ordering of conditions. Currently the SQL programmer can determine what happens by writing his query carefully --- if we reorder based on selectivity only, we could make things worse, and there'd be no way to override it. regards, tom lane