Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XTWI5-00073L-KT for pgsql-performance@arkaria.postgresql.org; Mon, 15 Sep 2014 13:26:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XTWI4-0002zu-SG for pgsql-performance@arkaria.postgresql.org; Mon, 15 Sep 2014 13:26:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XTWI4-0002zh-0l for pgsql-performance@postgresql.org; Mon, 15 Sep 2014 13:26:00 +0000 Received: from nm20-vm3.bullet.mail.ne1.yahoo.com ([98.138.91.150]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XTWHr-0001vW-Vb for pgsql-performance@postgresql.org; Mon, 15 Sep 2014 13:25:58 +0000 Received: from [98.138.101.128] by nm20.bullet.mail.ne1.yahoo.com with NNFMP; 15 Sep 2014 13:25:45 -0000 Received: from [98.138.89.248] by tm16.bullet.mail.ne1.yahoo.com with NNFMP; 15 Sep 2014 13:25:44 -0000 Received: from [127.0.0.1] by omp1040.mail.ne1.yahoo.com with NNFMP; 15 Sep 2014 13:25:44 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 984114.88316.bm@omp1040.mail.ne1.yahoo.com Received: (qmail 18390 invoked by uid 60001); 15 Sep 2014 13:25:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1410787544; bh=8ztZVXHV1Jq45+o+eEb6OdtYk/TOclC6fEqnsgqZLTE=; h=References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=X0szFP6J9EKOcuEF87vC5AHz/Jk9/dyQnYPhsYdzYEj48aFIuVaJflVlYnTz6cUZSyicgwqTmxnfrm3KUY+vTkIMLtqVitOykau4XInOTlnJC0ztFvhw1pWS5cSq5P/YjDvH3hc/ZcUlblPspDjvTmMmKi24z2JjzypzuCb2jo0= X-YMail-OSG: TjXCubMVM1ly_YNO78GJMzabiVEuj09Xqa_ejZamI5H1Yn1 ncff9nH2QhyB1AFPYVgBzHwbqMNZfOhV7u.SzFoRQN37HGWIXVXbOE3YvNkM jnvFKf7z7SUGCaUsCoh68dC785Ge608ClaRd_cVNuwm7Sd670DPXQNJ9xpcD b4Xuo1umqRPW.Oi7FL8I7gDlfRvLHRjfrqKMwCIRCby1cyZArdn25Sjbl_o5 gh.sxC1pj81li7246Cl3OA_sbt3.pnosPu58laHeAJpjjZfBjT5YKzkzko6t zpOYgY6vJa_b388LtCtbuV9CgIsxx0XC3rxVndSS4EzXVNlCrkT9kvJ_goPz FOK8ZBi7CIUM8TQ9xUboKAFWVJmtDvMtppTRoYP5c8Wrvah6FkTkmrmi8z4F gol.wdbwjsKX6sekTihv_ZJrj6MY_xncPmOtKeEyJK__mqMp.zAaVEOm3DYG 1NbilKGVasp5fGmZFeNpxw3Y91hv6z0Oe7L_ZYEKI5I_dQPW8pkq7UL51hM8 qqUgdLAks3IdMpnEHHVMopmGQV3b3DgBMXXl1XY53ROLJJiFOasHnrSi7dSL 6oqCJ.R4fsU86ekbMcPOjVBXwhAHwaJkpCCYnALlF.1kapiIqrMRHrdd8qdU Ml4zGvChbaUwCYbBTMh8dXn6vpTIjAVJib9HfaPae1.d1qUs- Received: from [24.178.25.147] by web122306.mail.ne1.yahoo.com via HTTP; Mon, 15 Sep 2014 06:25:44 PDT X-Rocket-MIMEInfo: 002.001, IlZhbiBEZXIgQmVyZywgU3RlZmFuIiA8U3ZhbmRlckJlcmdAZm5iLmNvLnphPiB3cm90ZToKCj4gSSBnZXQgYSBzaW1pbGFyIHBsYW4gc2VsZWN0ZWQgb24gdGhlIG9yaWdpbmFsIHF1ZXJ5IGlmIEkgc2V0Cgo.IGVuYWJsZV9zZXFzY2FuIHRvIG9mZi4gSSBtdWNoIHByZWZlciB0aGUgc2Vjb25kIHJlc3VsdC4KPiBNeSBxdWVzdGlvbnMgYXJlOgo.IDEuIFdoeSBpcyB0aGlzIGhhcHBlbmluZz8KCllvdXIgY29zdCBmYWN0b3JzIGRvbid0IGFjY3VyYXRlbHkgbW9kZWwgYWN0dWFsIGNvc3RzLgoKPiAyLiBIb3cBMAEBAQE- X-Mailer: YahooMailWebService/0.8.203.696 References: <5416B396.1080200@fnb.co.za> Message-ID: <1410787544.68356.YahooMailNeo@web122306.mail.ne1.yahoo.com> Date: Mon, 15 Sep 2014 06:25:44 -0700 From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: Strange performance problem with query To: "Van Der Berg, Stefan" , "pgsql-performance@postgresql.org" In-Reply-To: <5416B396.1080200@fnb.co.za> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org "Van Der Berg, Stefan" wrote: > I get a similar plan selected on the original query if I set > enable_seqscan to off. I much prefer the second result. > My questions are: > 1. Why is this happening? Your cost factors don't accurately model actual costs. > 2. How can I encourage the behavior of the second query without > changing the original query? You didn't give enough information to really give solid advice, but when people see what you are seeing, some common tuning needed is: Set shared_buffers to about 25% of system RAM or 8GB, whichever is lower. Set effective_cache_size to 50% to 75% of system RAM. Set work_mem to about 25% of system RAM divided by max_connections. If you have a high cache hit ratio (which you apparently do) reduce random_page_cost, possibly to something near or equal to seq_page_cost. Increase cpu_tuple_cost, perhaps to 0.03. You might want to play with the above, and if you still have a problem, read this page and post with more detail: http://wiki.postgresql.org/wiki/SlowQueryQuestions > Is there some column level setting I can set? The statistics looked pretty accurate, so that shouldn't be necessary. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance