Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 2D3D09F9AFF for ; Wed, 10 Oct 2007 09:51:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 93139-02 for ; Wed, 10 Oct 2007 09:51:25 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.178]) by postgresql.org (Postfix) with ESMTP id DBED29F961C for ; Wed, 10 Oct 2007 09:51:24 -0300 (ADT) Received: by el-out-1112.google.com with SMTP id r27so37896ele for ; Wed, 10 Oct 2007 05:51:22 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=R4G3vPJ0Yd/MZ35JFDgG1QicxqGjgfO/KF2lDPzq3vg=; b=tknF4ebg6OO7fmug3Luma5TIPLKB4WKgEgTTUxNyC7AQVwJfjJPaCAPrZC5TUxJ7JheHuzaEpK4BlD5e+6jx7nKACHyk6W4AEWiqawEg0RPBSp0eyNjFnJQUTzGO+KECZgycLDubNfPPmbWEEUpBE0Xo61y5DonpCvwQYrPelZA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=A48MevtmxOkHURfnnRDmUNMuGOYlOKpkQUxpgDX1OvqYUU0tBQRg9HeJuvpjSDllnOLqUvW0dqgxqMnFi4hEkFyV+U5dm9sHibrcxY8ztsC21/qx5v/LhUH9GqXNAuhODVhPGumus6+TN4utjP8QmBe3BT8wZLbHyi3EpSrX/Ng= Received: by 10.142.154.20 with SMTP id b20mr51802wfe.1192020681726; Wed, 10 Oct 2007 05:51:21 -0700 (PDT) Received: by 10.142.11.1 with HTTP; Wed, 10 Oct 2007 05:51:21 -0700 (PDT) Message-ID: Date: Wed, 10 Oct 2007 13:51:21 +0100 From: "James Shaw" To: "Tom Lane" Subject: Re: Possible mistake in 'Using EXPLAIN' section Cc: pgsql-docs@postgresql.org In-Reply-To: <13020.1192018254@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <13020.1192018254@sss.pgh.pa.us> X-Google-Sender-Auth: 45a8c2c0784d5715 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/32 X-Sequence-Number: 4453 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. Thanks James