Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1A5976328C8 for ; Wed, 24 Mar 2010 23:17:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 03124-01 for ; Thu, 25 Mar 2010 02:16:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f224.google.com (mail-fx0-f224.google.com [209.85.220.224]) by mail.postgresql.org (Postfix) with ESMTP id 3C7A7632269 for ; Wed, 24 Mar 2010 23:17:04 -0300 (ADT) Received: by fxm24 with SMTP id 24so2733534fxm.3 for ; Wed, 24 Mar 2010 19:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=NX3qgczF7iXgZu4vQvJC0w8tf6RZR1T5XWx20Lkh+sY=; b=IM231nsXqBmLt6c2noh0hXrpg9flmdM0xXpjfZACvEtIzeftUzMdq9EUqXhbMR2XP7 18BnywJ+3+9DIyimhEh/dmh3gwsFVSSsFXvbybF1fYkc/XuPbSQF/x7knmgQsWyjK2cp GKVio0mUutfr3wd0iTInagfeiYl2quQgGslNE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=ZzDbcjjOnDBJHHQdTpyNRf2uvnM1VJNUhECxCHWSth8Cs5f1wzEM0cd8SL1J5ZF2d7 mtJMkimjKWksICuHVaWe0byrC/5WGKzNY0t4ULbfdIHxBVjwAgFWZNTBqWz8BiU0gMFU pN2CT1pq7Lqq2gp1m+tJ7RjhrIS7vmiRD9+Yw= MIME-Version: 1.0 Received: by 10.239.148.12 with SMTP id d12mr636704hbb.158.1269483419327; Wed, 24 Mar 2010 19:16:59 -0700 (PDT) In-Reply-To: <1CFD7891521AAB4E8201FB7A78C9D36F05454451@mail-001.corp.automotive.com> References: <4BA148CF.5080701@r-stream.com> <1CFD7891521AAB4E8201FB7A78C9D36F05453FD7@mail-001.corp.automotive.com> <603c8f071003241746i4713bc8fgc55357486d3f0bd3@mail.gmail.com> <1CFD7891521AAB4E8201FB7A78C9D36F05454451@mail-001.corp.automotive.com> Date: Wed, 24 Mar 2010 22:16:59 -0400 Message-ID: <603c8f071003241916t8babf14jd8e499a6591be97b@mail.gmail.com> Subject: Re: Forcing index scan on query produces 16x faster From: Robert Haas To: "Eger, Patrick" Cc: Christian Brink , pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.482 tagged_above=-10 required=5 tests=AWL=0.117, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/314 X-Sequence-Number: 38139 On Wed, Mar 24, 2010 at 8:59 PM, Eger, Patrick wrote: > Ok, the wording is a bit unclear in the documentation as to whether it is the cost for an entire *page* of tuples, or actual tuples. So something like the following might give better results for a fully-cached DB? > > seq_page_cost = 1.0 > random_page_cost = 1.1 #even memory has random access costs, lack of readahead, TLB misses, etc > cpu_tuple_cost = 1.0 > cpu_index_tuple_cost = 0.5 > cpu_operator_cost = 0.25 > effective_cache_size = 1000MB > shared_buffers = 1000MB Yeah, you can do it that way, by jacking up the cpu_tuple costs. I prefer to lower the {random/seq}_page_cost values because it keeps the cost values in the range I'm used to seeing, but it works out to the same thing. I am not sure that there is any benefit from making random_page_cost > seq_page_cost on a fully cached database. What does readahead mean in the context of cached data? The data isn't likely physically contiguous in RAM, and I'm not sure it would matter much if it were. Basically, what random_page_cost > seq_page_cost tends to do is discourage the use of index scans in borderline cases, so you want to benchmark it and figure out which way is faster and then tune accordingly. ...Robert