X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 22F729FB202 for ; Wed, 13 Sep 2006 19:08:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 12144-06 for ; Wed, 13 Sep 2006 22:08:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id D9C149FB200 for ; Wed, 13 Sep 2006 19:08:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k8DM8gGt018009; Wed, 13 Sep 2006 18:08:42 -0400 (EDT) To: "Joshua Marsh" cc: "Terje Elde" , "Jeff Davis" , pgsql-performance@postgresql.org, jim@nasby.net Subject: Re: Performance With Joins on Large Tables In-reply-to: <38242de90609131445p5044fa67p3752e1bc7f699da2@mail.gmail.com> References: <38242de90609121517y62517040v8622b9ae93cba23d@mail.gmail.com> <38242de90609130749u976295fwb10904ff4797b920@mail.gmail.com> <1158163655.29889.57.camel@dogma.v10.wvs> <38242de90609130919k33208204ka1006ff0ca25f75b@mail.gmail.com> <1158167054.29889.72.camel@dogma.v10.wvs> <45085F3A.1040108@elde.net> <38242de90609131327o68d2866fh92c12ddcf364aba7@mail.gmail.com> <16645.1158181784@sss.pgh.pa.us> <38242de90609131418j43d0dc88q3cb8a52dcceec287@mail.gmail.com> <16941.1158182624@sss.pgh.pa.us> <38242de90609131445p5044fa67p3752e1bc7f699da2@mail.gmail.com> Comments: In-reply-to "Joshua Marsh" message dated "Wed, 13 Sep 2006 15:45:12 -0600" Date: Wed, 13 Sep 2006 18:08:42 -0400 Message-ID: <18008.1158185322@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200609/143 X-Sequence-Number: 20829 "Joshua Marsh" writes: >>> On 9/13/06, Tom Lane wrote: >>>> Are the tables perhaps nearly in order by the dsiacctno fields? >> >>> My assumption would be they are in exact order. The text file I used >>> in the COPY statement had them in order, so if COPY preserves that in >>> the database, then it is in order. >> >> Ah. So the question is why the planner isn't noticing that. What do >> you see in the pg_stats view for the two dsiacctno fields --- the >> correlation field in particular? > Here are the results: > data=# select tablename, attname, n_distinct, avg_width, correlation > from pg_stats where tablename in ('view_505', 'r3s169') and attname = > 'dsiacctno'; > tablename | attname | n_distinct | avg_width | correlation > -----------+-----------+------------+-----------+------------- > view_505 | dsiacctno | -1 | 13 | -0.13912 > r3s169 | dsiacctno | 44156 | 13 | -0.126824 > (2 rows) Wow, that correlation value is *way* away from order. If they were really in exact order by dsiacctno then I'd expect to see 1.0 in that column. Can you take another look at the tables and confirm the ordering? Does the correlation change if you do an ANALYZE on the tables? (Some small change is to be expected due to random sampling, but this is way off.) regards, tom lane