Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 3A9CE475EE7 for ; Wed, 27 Feb 2002 17:55:29 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 6227BD5FA; Wed, 27 Feb 2002 14:55:27 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 57ABD5BFB; Wed, 27 Feb 2002 14:55:27 -0800 (PST) Date: Wed, 27 Feb 2002 14:55:27 -0800 (PST) From: Stephan Szabo To: "Zhang, Anna" Cc: "Pgsql-Admin (E-mail)" Subject: Re: optimizer In-Reply-To: <5511D658682A7740BA295CCF1E1233A635A861@vsvapostal2.bkup3> Message-ID: <20020227145230.D8222-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200202/379 X-Sequence-Number: 3532 On Wed, 27 Feb 2002, Zhang, Anna wrote: > > >Is the estimate above (1.5M rows) reasonable? If so, it's probably > >doing the right thing. If not, what version are you using and are > >there any very common values that may throw off the estimates; what > >does select * from pg_statistic where starelid=(select oid from > >pg_class where relname='domain'); give? Okay, does running it after set enable_seqscan=false; actually run faster than the sequence scan version? > select * from pg_statistic where starelid=(select oid from pg_class where > relname='domain'); > > starelid | staattnum | staop | stanullfrac | stacommonfrac | > stacommonval | staloval | > > stahival > -----------+-----------+-------+-------------+---------------+-------------- > --------------+------------------------------+------------------------------ > ----------------------------------- > 749413081 | 1 | 664 | 0 | 7.02145e-08 | UPSPWR-DOM > > | 000000000000000000000-N3-DOM | ZZZZZZZZZZZZZZZZZZZZZ9-DOM > 749413081 | 2 | 664 | 0 | 7.02145e-08 | UPSPWR > > | 00 | > ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ > 749413081 | 3 | 664 | 0 | 0.728349 | COM > > | ARPA | WS > 749413081 | 4 | 664 | 0 | 0.107595 | NAMEZERO.COM > > | ` | ambassador blinds > 749413081 | 5 | 664 | 0 | 0.107594 | 51 University > Ave, Suite K | - | zzzzzzzzzzzzzzzzzz > zzzzzzzzzzzzzzzz, zzzzzzzzzzz 325698 > 749413081 | 6 | 664 | 0.312378 | 0.107716 | LOS GATOS > > | - | Murray > 749413081 | 7 | 664 | 0.312378 | 0.227842 | CA > > | AA | WY > 749413081 | 8 | 664 | 0.312119 | 0.107774 | 95030 > > | 00005 | 99995 > 749413081 | 9 | 664 | 0.00980173 | 0.687646 | US > > | AC | ZW > (9 rows) > > The column holdername is not common, same holdername may have a few records. > I am running postgres 7.2, for pg_statistic table I really no idea what each Are you *sure* this is a 7.2 server? The above looks like the form from 7.1 and earlier. In any case, it looks like NAMEZERO.COM is the most common value with about 10% of the table, so I don't think sequence scan is a bad plan necessarily.