Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 44F8D420B3A for ; Wed, 1 Feb 2012 17:48:48 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rsi2q-00048v-8t for pgsql-bugs@postgresql.org; Wed, 01 Feb 2012 21:48:48 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q11LmZG2024545; Wed, 1 Feb 2012 16:48:35 -0500 (EST) To: Andrew Schetinin cc: Alex Lai , pgsql-bugs@postgresql.org Subject: Re: BUG #6426: Complex query runs 10 times longer with "LIMIT 20" In-reply-to: References: <4F2995BB.6050708@sesda2.com> Comments: In-reply-to Andrew Schetinin message dated "Wed, 01 Feb 2012 22:05:15 +0200" Date: Wed, 01 Feb 2012 16:48:35 -0500 Message-ID: <24544.1328132915@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/22 X-Sequence-Number: 32365 Andrew Schetinin writes: > In my specific case, what I've seen from the query execution plans, is that > without LIMIT the query uses Hash Joins, but once I add LIMIT, it starts > using Nested Loop Joins almost everywhere. Usually, that's an appropriate change for a small LIMIT. It's certainly not a priori evidence of a planner bug. If you want useful comments about this, please review http://wiki.postgresql.org/wiki/Slow_Query_Questions about how to provide an adequate description of your problem. regards, tom lane