X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D2742528EB for ; Fri, 29 Jul 2005 15:45:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15871-02 for ; Fri, 29 Jul 2005 18:45:24 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 58B9852938 for ; Fri, 29 Jul 2005 15:45:23 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j6TIjF2K029833 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Jul 2005 12:45:18 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j6TIjFp5098578; Fri, 29 Jul 2005 12:45:15 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j6TIjFEt098577; Fri, 29 Jul 2005 12:45:15 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 29 Jul 2005 12:45:15 -0600 From: Michael Fuhr To: Lee Wu Cc: pgsql-admin@postgresql.org Subject: Re: rows in explain Message-ID: <20050729184515.GA98486@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/256 X-Sequence-Number: 18312 On Fri, Jul 29, 2005 at 11:54:18AM -0600, Lee Wu wrote: > explain select count(*) from pg_class where relname='pg_class'; > QUERY PLAN > -------------------------------------------------------------- > Aggregate (cost=4.55..4.55 rows=1 width=0) > -> Seq Scan on pg_class (cost=0.00..4.55 rows=1 width=0) > Filter: (relname = 'pg_class'::name) > (3 rows) > > Where and how PG get "rows=1"? The planner uses statistics to estimate the number of rows that a query will return. Here are a couple of links that provide more information: http://www.postgresql.org/docs/8.0/static/planner-stats.html http://www.postgresql.org/docs/8.0/static/view-pg-stats.html http://www.postgresql.org/docs/8.0/static/sql-analyze.html http://developer.postgresql.org/docs/postgres/planner-stats-details.html -- Michael Fuhr http://www.fuhr.org/~mfuhr/