Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TRDEz-000269-9p for pgsql-bugs@postgresql.org; Thu, 25 Oct 2012 02:32:13 +0000 Received: from mailout-us.gmx.com ([74.208.5.67]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TRDEr-0006Gg-Pu for pgsql-bugs@postgresql.org; Thu, 25 Oct 2012 02:32:12 +0000 Received: (qmail 29301 invoked by uid 0); 25 Oct 2012 01:56:49 -0000 Received: from 76.255.19.161 by rms-us009 with HTTP Cc: pgsql-bugs@postgresql.org Content-Type: text/plain; charset="utf-8" Date: Wed, 24 Oct 2012 21:56:48 -0400 From: "Kevin Grittner" Message-ID: <20121025015648.306900@gmx.com> MIME-Version: 1.0 Subject: Re: BUG #7619: Query cost estimate appears to not use n_distinct setting To: "Tom Lane" ,niko.kiirala@mapvision.fi X-Authenticated: #138763884 X-Flags: 0001 X-Mailer: GMX.com Web Mailer x-registered: 0 Content-Transfer-Encoding: 8bit X-GMX-UID: N/n6cIYW3zOlOQ09Lnwhzkx+IGRvb0DM X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/223 X-Sequence-Number: 34523 Tom Lane wrote: > plus some not-very-large CPU-per-tuple charges In my experience, cpu_tuple_cost should be higher. I've often had to boost it to get good plans for a wide mix of queries in a load. Doubling it to 0.02 is often not enough to get good plans. I've taken it to 0.05 with production workloads without ill effect, but personally have not seen further improvements beyond the plans I got at 0.03. Among other things, this setting tends to make the ratio between random_page_cost and seq_page_cost somewhat less sensitive; although I still find it best to take them both down to 0.1 for fully cached workloads, along with the cpu_tuple_cost boost. I think we should raise the default for cpu_tuple_cost, but have been reluctant to suggest it based on just my personal experiences. Has anyone else found this useful? -Kevin