Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 077FE2E00F5 for ; Fri, 16 May 2008 05:33:20 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 49703-05-2 for ; Fri, 16 May 2008 05:32:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from pih-relay08.plus.net (pih-relay08.plus.net [212.159.14.134]) by developer.postgresql.org (Postfix) with ESMTP id 45D5B2E022F for ; Fri, 16 May 2008 05:18:15 -0300 (ADT) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay08.plus.net with esmtp (Exim) id 1Jwv8m-0006XQ-PP; Fri, 16 May 2008 09:18:13 +0100 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id A236527405A; Fri, 16 May 2008 09:18:12 +0100 (BST) Message-ID: <482D4344.2060607@archonet.com> Date: Fri, 16 May 2008 09:18:12 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.14 (X11/20080421) MIME-Version: 1.0 To: kevin kempter CC: pgsql-performance@postgresql.org Subject: Re: Join runs for > 10 hours and then fills up >1.3TB of disk space References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: 4b45b600e2176947551fafa2fd61233d X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/241 X-Sequence-Number: 30209 kevin kempter wrote: > Hi List; > > I have a table with 9,961,914 rows in it (see the describe of > bigtab_stats_fact_tmp14 below) > > I also have a table with 7,785 rows in it (see the describe of > xsegment_dim below) Something else is puzzling me with this - you're joining over four fields. > from > bigtab_stats_fact_tmp14 f14, > xsegment_dim segdim > where > f14.customer_id = segdim.customer_srcid > and f14.show_id = segdim.show_srcid > and f14.season_id = segdim.season_srcid > and f14.episode_id = segdim.episode_srcid > and segdim.segment_srcid is NULL; > --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Merge Join (cost=1757001.74..73569676.49 rows=3191677219 width=118) > -> Sort (cost=1570.35..1579.46 rows=3643 width=40) > -> Sort (cost=1755323.26..1780227.95 rows=9961874 width=126) Here it's still expecting 320 matches against each row from the large table. That's ~ 10% of the small table (or that fraction of it that PG expects) which seems very high for four clauses ANDed together. -- Richard Huxton Archonet Ltd