X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id BD4299FA278 for ; Thu, 25 May 2006 20:27:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 51893-06 for ; Thu, 25 May 2006 20:27:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz [203.96.152.184]) by postgresql.org (Postfix) with ESMTP id 1B39B9F9B14 for ; Thu, 25 May 2006 20:27:47 -0300 (ADT) Received: from smtp-3.paradise.net.nz (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IZU00NEWH684G@linda-5.paradise.net.nz> for pgsql-performance@postgresql.org; Fri, 26 May 2006 11:27:45 +1200 (NZST) Received: from [192.168.1.11] (218-101-29-172.dsl.clear.net.nz [218.101.29.172]) by smtp-3.paradise.net.nz (Postfix) with ESMTP id 7560814D423E; Fri, 26 May 2006 11:27:44 +1200 (NZST) Date: Fri, 26 May 2006 11:27:09 +1200 From: Mark Kirkwood Subject: Re: Optimizing a huge_table/tiny_table join In-reply-to: <7082.1148521319@sss.pgh.pa.us> To: kynn@panix.com Cc: Tom Lane , pgsql-performance@postgresql.org Message-id: <44763D4D.6090305@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit User-Agent: Thunderbird 1.5 (X11/20060417) References: <200605250052.k4P0qrT11965@panix3.panix.com> <7082.1148521319@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/485 X-Sequence-Number: 19272 Tom Lane wrote: > writes: >> Limit (cost=19676.75..21327.99 rows=6000 width=84) >> -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) >> Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) >> -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) >> -> Hash (cost=19676.00..19676.00 rows=300 width=38) >> -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) > > Um, if huge_table is so much bigger than tiny_table, why are the cost > estimates for seqscanning them only about 2.5x different? There's > something wacko about your statistics, methinks. > This suggests that tiny_table is very wide (i.e a lot of columns compared to huge_table), or else has thousands of dead tuples. Do you want to post the descriptions for these tables? If you are running 8.1.x, then the output of 'ANALYZE VERBOSE tiny_table' is of interest too. If you are running a pre-8.1 release, then lets see 'VACUUM VERBOSE tiny_table'. Note that after either of these, your plans may be altered (as ANALYZE will recompute your stats for tiny_table, and VACUUM may truncate pages full of dead tuples at the end of it)!