X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BDA315280B for ; Wed, 8 Jun 2005 14:39:18 -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 95818-10 for ; Wed, 8 Jun 2005 17:39:17 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3130152816 for ; Wed, 8 Jun 2005 14:39:16 -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 j58HdGP0009066; Wed, 8 Jun 2005 13:39:16 -0400 (EDT) To: allanvv@gmail.com Cc: pgsql-performance@postgreSQL.org Subject: Re: Performance problems, bad estimates and plan In-reply-to: <1118250631.3454.6.camel@localhost> References: <1118243044.3454.3.camel@localhost> <4362.1118250155@sss.pgh.pa.us> <1118250631.3454.6.camel@localhost> Comments: In-reply-to Allan Wang message dated "Wed, 08 Jun 2005 13:10:31 -0400" Date: Wed, 08 Jun 2005 13:39:16 -0400 Message-ID: <9065.1118252356@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/180 X-Sequence-Number: 12817 Allan Wang writes: > On Wed, 2005-06-08 at 13:02 -0400, Tom Lane wrote: >> Are you running 7.4.8 or 8.0.2 or later? > I'm running 8.0.2 on Gentoo. Oh, OK [ looks again ... ] I read the join backward, the issue I was concerned about would've applied to a right join there not left. The seqscan vs indexscan difference is a red herring: if you look at the explain output, the only thing that changes to an indexscan is the scan on cities, which is only two rows and is not taking any time anyway. The thing that is taking a long time (or not) is the indexscan over players. The planner is expecting that to stop short of completion (presumably based on comparing the maximum values of playerid in the two tables) --- and in one plan it does so, so the planner's logic is apparently correct. Are there any NULLs in c.playerid? We found an executor issue recently that it would not figure out it could stop the scan if there was a NULL involved. regards, tom lane