Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z5xjv-0004Cp-85 for pgsql-performance@arkaria.postgresql.org; Fri, 19 Jun 2015 14:57:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z5xju-0007yk-OA for pgsql-performance@arkaria.postgresql.org; Fri, 19 Jun 2015 14:57:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z5xjt-0007wA-4W for pgsql-performance@postgresql.org; Fri, 19 Jun 2015 14:57:53 +0000 Received: from resqmta-ch2-09v.sys.comcast.net ([2001:558:fe21:29:69:252:207:41]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z5xjl-00088E-Er for pgsql-performance@postgresql.org; Fri, 19 Jun 2015 14:57:51 +0000 Received: from resomta-ch2-05v.sys.comcast.net ([69.252.207.101]) by resqmta-ch2-09v.sys.comcast.net with comcast id iExF1q0022Bo0NV01ExiLk; Fri, 19 Jun 2015 14:57:42 +0000 Received: from [10.0.0.151] ([173.166.19.109]) by resomta-ch2-05v.sys.comcast.net with comcast id iExh1q00N2MCEZH01Exh8i; Fri, 19 Jun 2015 14:57:42 +0000 Message-ID: <55842DF1.9040208@intuvisiontech.com> Date: Fri, 19 Jun 2015 10:57:53 -0400 From: Ian Pushee User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Slow query (planner insisting on using 'external merge' sort type) References: <55842859.4060102@intuvisiontech.com> <1405767375.375868.1434725229563.JavaMail.open-xchange@oxweb02.ims-firmen.de> In-Reply-To: <1405767375.375868.1434725229563.JavaMail.open-xchange@oxweb02.ims-firmen.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1434725862; bh=xukXUhXnhKbromL7mPn91JIAOchOeDka0kjZIkdZ02c=; h=Received:Received:Message-ID:Date:From:MIME-Version:To:Subject: Content-Type; b=s6yNp0X0Tw1i0cPgI0Of1HmrgXFzY7yO6Nk8H1QKe/OOUJtRA97n0hyi+P+/cYkva GMgc5fvhC8PASY7BnczBvDvCU2Lx+HXW4jzZ73CE5Kwwcx4hngx7mTycCE6ZyjVh2+ Fyk8HdR+aUrbvTRU4MxoQiv2V3h1CjSIyDcYWLD08TmNq8TLdA/ENIL9ZdBY4UZpAM MUDqrtjpPsBSOPrxlQaD6D8Q0WbXhE6o8U47g8+ELKrQngPjniUhyuYHOJHPBJl3FA OClMsRg1yIZs9OoPAZGbk5C+vmgKkN1kTLV6fSZJC26D6Gz0vuKBeVu9p+MYeXYa3T uizMYxFLsW6Cg== X-Pg-Spam-Score: -2.6 (--) 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 On 6/19/2015 10:47 AM, Andreas Kretschmer wrote: >> Explain Analyze outputs (links as requested): >> Default plan: http://explain.depesz.com/s/ib3k >> Forced index (random_page_cost=1.0): http://explain.depesz.com/s/lYaP >> >> Software/Hardware: PGSql 9.2.1, Windows 8.1, 8GB RAM >> All pgsql settings are at their defaults. > increase work_mem. per session via set work_mem = 'xxxMB'; or in > postgresql.conf, reload. > > Hi Andreas, The number of rows in the events table isn't constrained, so unfortunately it isn't feasible to set work_mem high enough to allow an in-memory sort. Forcing the planner to use the index works to produce a fast query, so I'm wondering if there is a more general way to getting the planner to take into account that work_mem isn't big enough to fit the query which will result in a MUCH more costly external merge. Thanks, -Ian -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance