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 EB1EB54FDB for ; Fri, 4 Mar 2005 15:22:58 +0000 (GMT) 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 93644-02 for ; Fri, 4 Mar 2005 15:22:52 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8EB4254E9E for ; Fri, 4 Mar 2005 15:22:52 +0000 (GMT) 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 j24FMuYF027482; Fri, 4 Mar 2005 10:22:56 -0500 (EST) To: Ron Mayer Cc: pgsql-performance@postgresql.org Subject: Re: Query's fast standalone - slow as a subquery. In-reply-to: References: <20050304002724.650A95AF649@svr4.postgresql.org> Comments: In-reply-to Ron Mayer message dated "Fri, 04 Mar 2005 03:27:23 -0800" Date: Fri, 04 Mar 2005 10:22:56 -0500 Message-ID: <27481.1109949776@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/72 X-Sequence-Number: 10777 Ron Mayer writes: > -> Seq Scan on points (cost=0.00..444.43 rows=1 width=82) (actual time=0.096..132.255 rows=15743 loops=1) > Filter: (the_geom && '010300000001000000050000009A99999999D95EC0295C8FC2F5A839409A99999999D95EC0F6285C8FC295454048E17A14AE7758C0F6285C8FC295454048E17A14AE7758C0295C8FC2F5A839409A99999999D95EC0295C8FC2F5A83940'::geometry) > -> Seq Scan on points (cost=0.00..444.43 rows=15794 width=82) (actual time=0.067..94.307 rows=15743 loops=1) > Filter: (the_geom && '010300000001000000050000009A99999999D95EC0295C8FC2F5A839409A99999999D95EC0F6285C8FC295454048E17A14AE7758C0F6285C8FC295454048E17A14AE7758C0295C8FC2F5A839409A99999999D95EC0295C8FC2F5A83940'::geometry) Apparently the selectivity of the && condition is misestimated in the first case (note the radically wrong rowcount estimate), leading to an inefficient join plan choice. I suppose this is a bug in the postgis selectivity routines --- better complain to them. regards, tom lane