Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B3DD8B5F900 for ; Mon, 6 Jun 2011 18:46:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 04629-01 for ; Mon, 6 Jun 2011 21:45:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-1.01.com (smtp-1.01.com [38.102.63.180]) by mail.postgresql.org (Postfix) with ESMTP id 30F22B5F90C for ; Mon, 6 Jun 2011 18:45:48 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-1.01.com (Postfix) with ESMTP id 87FAC364B2E for ; Mon, 6 Jun 2011 16:45:48 -0500 (CDT) Received: from smtp-1.01.com ([127.0.0.1]) by localhost (smtp-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yDJoKLJqXRk8 for ; Mon, 6 Jun 2011 16:45:48 -0500 (CDT) Received: by smtp-1.01.com (Postfix, from userid 99) id 58BC2364A22; Mon, 6 Jun 2011 16:45:45 -0500 (CDT) Received: from Sidney-Stratton.local (70-36-143-243.dsl.dynamic.sonic.net [70.36.143.243]) by smtp-1.01.com (Postfix) with ESMTPSA id 0BBDD3645BC for ; Mon, 6 Jun 2011 16:45:44 -0500 (CDT) Message-ID: <4DED4A87.7000901@agliodbs.com> Date: Mon, 06 Jun 2011 14:45:43 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: 8.4/9.0 simple query performance regression X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/37 X-Sequence-Number: 43970 All, Just got this simple case off IRC today: 8.4.4 This plan completes in 100ms: old_prod=# explain analyze select email from u_contact where id not in (select contact_id from u_user); QUERY PLAN -------------------------------------------------------------------------------------------------------------------- Seq Scan on u_contact (cost=2217.72..4759.74 rows=35560 width=22) (actual time=61.283..107.169 rows=4521 loops=1) Filter: (NOT (hashed SubPlan 1)) SubPlan 1 -> Seq Scan on u_user (cost=0.00..2051.38 rows=66538 width=8) (actual time=0.034..33.303 rows=66978 loops=1) Total runtime: 108.001 ms 9.0.2 This plan does not complete in 15 minutes or more: new_prod=# explain select email from u_contact where id not in (select contact_id from u_user); QUERY PLAN --------------------------------------------------------------------------- Seq Scan on u_contact (cost=0.00..100542356.74 rows=36878 width=22) Filter: (NOT (SubPlan 1)) SubPlan 1 -> Materialize (cost=0.00..2552.56 rows=69504 width=8) -> Seq Scan on u_user (cost=0.00..1933.04 rows=69504 width=8) (5 rows) I'm at a bit of a loss as to what's happening here. I'd guess another failure of a bail-out-early plan, but I can't see how that would work with this query. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com