Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TWsm9-0003Rh-2N for pgsql-performance@postgresql.org; Fri, 09 Nov 2012 17:53:53 +0000 Received: from moutng.kundenserver.de ([212.227.17.9]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TWsm5-0007xF-Kd for pgsql-performance@postgresql.org; Fri, 09 Nov 2012 17:53:52 +0000 Received: from anarazel.de (p5DDC7583.dip.t-dialin.net [93.220.117.131]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0MGGwx-1TaVfY0Uqd-00EqFn; Fri, 09 Nov 2012 18:53:47 +0100 Received: by anarazel.de (Postfix, from userid 1000) id 1DCDD1C0177; Fri, 9 Nov 2012 18:53:46 +0100 (CET) Date: Fri, 9 Nov 2012 18:53:45 +0100 From: Andres Freund To: Petr Praus Cc: pgsql-performance@postgresql.org Subject: Re: Increasing work_mem and shared_buffers on Postgres 9.2 significantly slows down queries Message-ID: <20121109175345.GA16999@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2011-07-01) X-Provags-ID: V02:K0:CcXUEKgLxezMTct383jdTBUAAx/EIshdocyu2I9PtS8 CEU76QEj6G3So8ryWMQWgi4nUSSUSPfU48QYDJ3l/SM/yJgsVo AEONQlCxNGOzQcEsJoJqazKnCWSNVhJRCU8ics1KxTbpuIhNxo NP644L9KYWtotL9qDorlLp117aKvsWnPAfkxVlElnjdEondU3Z B09za6RsALltQzYGtUQ5oKfaSY0FDWQwl9/zib6fxs9fJxiI9T zUHmHNZSHuZodP54EUpTXANig6oM8QZ5w8sxgn30I5xWGnSJh1 yhviYqMrMYcipzbdr3jwvhZmJOixnJzkPj5jVQ+Jlo8QjnI9ua HeKE+UwJ5RWyHQCcvjyhBGCL7nSEhh0CM2nyOI4+6 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201211/119 X-Sequence-Number: 48485 On 2012-10-30 14:08:56 -0500, Petr Praus wrote: > select count(*) from contest c > left outer join contestparticipant cp on c.id=cp.contestId > left outer join teammember tm on tm.contestparticipantid=cp.id > left outer join staffmember sm on cp.id=sm.contestparticipantid > left outer join person p on p.id=cp.personid > left outer join personinfo pi on pi.id=cp.personinfoid > where pi.lastname like '%b%' or pi.firstname like '%a%'; Btw, not really related to the question, but the way you use left joins here doesn't really make sense and does lead to inferior plans. As you restrict on 'pi', the rightmost table in a chain of left joins, there is no point in all those left joins. I would guess the overall plan is better if use straight joins. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services