Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C49EE9F9FC5 for ; Mon, 22 Oct 2007 09:14:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 60634-03 for ; Mon, 22 Oct 2007 09:14:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.239]) by postgresql.org (Postfix) with ESMTP id F36209F9A90 for ; Mon, 22 Oct 2007 09:14:41 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id l8so365742nzf for ; Mon, 22 Oct 2007 05:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; bh=UGv4oJxuK0aNh93AbELgcebXeo1Nl9LQlZp5gQjwHtM=; b=FTNTgTKNF7TEA/IrDVwia3lpKMzgEUaDaCfFGlwvf8zKyO2U8UBttsG3Kp9v1H6Gd3uzPYcL+/RUKS9qSPh4N5iO0yMIIucRZr6uw+daNxoATx/HGqEA7MWWKj2Y7Lddq/Ihmcp6vpSnDe+AAmv+brQ6+Exi2opAU5mbbnm/nus= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=dlCa0uwqUeqz3SkcxgMJwbj9bfo24qeuZAZ9RW2R57MuLAynZCbbPbJTJP7Assnt5IFRYqoF6SjsXn8uxPYCWSE3C5igFvMXMDuCNPecUA1IGrAgptyvysBFI2ABy59sK6YbKplhu9Wr68cXSjYdk/onmDXloHtMBwBvCuLIlbQ= Received: by 10.143.161.3 with SMTP id n3mr1154905wfo.1193055277815; Mon, 22 Oct 2007 05:14:37 -0700 (PDT) Received: by 10.142.11.1 with HTTP; Mon, 22 Oct 2007 05:14:37 -0700 (PDT) Message-ID: Date: Mon, 22 Oct 2007 13:14:37 +0100 From: "James Shaw" To: pgsql-docs@postgresql.org Subject: Re: Possible mistake in 'Using EXPLAIN' section In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_9137_19042203.1193055277818" References: <13020.1192018254@sss.pgh.pa.us> X-Google-Sender-Auth: 3d06245fd25a39f1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/74 X-Sequence-Number: 4495 ------=_Part_9137_19042203.1193055277818 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/10/2007, James Shaw wrote: > > On 10/10/2007, Tom Lane wrote: > > "James Shaw" writes: > > > The example given has "Seq Scan on tenk1 (cost=0.00..458.00" in the > example, > > > but then says, "you will find out that tenk1 has 358 disk pages" and > "the > > > cost is estimated at 358 page reads". Shouldn't this be 458 disk page > > > reads? > > > > No. Why did you stop reading in mid-sentence? > > I'm sorry, I misunderstood. I've reread, and understand where the > extra 100 comes from now. Perhaps this could be reworded: > > This is about as straightforward as it gets. If you do > SELECT relpages, reltuples FROM pg_class WHERE relname = 'tenk1'; > > you will find out that tenk1 has 358 disk pages and 10000 rows. The > estimated cost is (disk pages read * seq_page_cost) + (number of rows > read * cpu_tuple_cost). By default, seq_page_cost is 1.0 and > cpu_tuple_cost is 0.01. Therefore, the estimated cost is (358 * 1.0) > + (10000 * 0.01) = 458. Were there any thoughts on this? I was hoping this might be included in the manual, since I felt it was somewhat clearer. James ------=_Part_9137_19042203.1193055277818 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/10/2007, James Shaw <js102@zepler.net> wrote:
On 10/10/2007, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "James Shaw" <js102@zepler.net> writes:
> > The example given has "Seq Scan on tenk1 (cost= 0.00..458.00" in the example,
> > but then says, "you will find out that tenk1 has 358 disk pages" and "the
> > cost is estimated at 358 page reads".  Shouldn't this be 458 disk page
> > reads?
>
> No.  Why did you stop reading in mid-sentence?

I'm sorry, I misunderstood.  I've reread, and understand where the
extra 100 comes from now.  Perhaps this could be reworded:

This is about as straightforward as it gets.  If you do
SELECT relpages, reltuples FROM pg_class WHERE relname = 'tenk1';

you will find out that tenk1 has 358 disk pages and 10000 rows.  The
estimated cost is (disk pages read * seq_page_cost) + (number of rows
read * cpu_tuple_cost).  By default, seq_page_cost is 1.0 and
cpu_tuple_cost is 0.01.  Therefore, the estimated cost is (358 * 1.0)
+ (10000 * 0.01) = 458.

Were there any thoughts on this?  I was hoping this might be included in the manual, since I felt it was somewhat clearer.

James
------=_Part_9137_19042203.1193055277818--