Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id EBED2E39AE1 for ; Tue, 31 Jul 2012 19:13:21 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SwKgr-0002nL-6A for pgsql-bugs@postgresql.org; Tue, 31 Jul 2012 22:13:21 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q6VMD7SX016672; Tue, 31 Jul 2012 18:13:07 -0400 (EDT) From: Tom Lane To: gsaviane@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6787: Query planner estimates worng costs on nodes In-reply-to: References: Comments: In-reply-to gsaviane@gmail.com message dated "Tue, 31 Jul 2012 15:06:36 -0000" Date: Tue, 31 Jul 2012 18:13:07 -0400 Message-ID: <16671.1343772787@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/247 X-Sequence-Number: 33723 gsaviane@gmail.com writes: > It seems the cost assigned to a sequential scan over 120 million records is > too low or, on the other side, the cost assigned to two nested loop over > three indexes is too high. It looks from here like you are measuring a situation where vb_product_readings is fully cached in RAM. If that's the normal situation in your database, then you ought to decrease the random_page_cost setting to make the planner's cost estimates reflect your reality. The default setting is intended to model situations where a fair amount of disk access is going to happen. regards, tom lane