Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id A0F101EC5BE6 for ; Thu, 2 Feb 2012 12:40:45 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RsziH-0005T6-Ch for pgsql-bugs@postgresql.org; Thu, 02 Feb 2012 16:40:45 +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 q12GeWLe025500; Thu, 2 Feb 2012 11:40:32 -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> <24544.1328132915@sss.pgh.pa.us> Comments: In-reply-to Andrew Schetinin message dated "Thu, 02 Feb 2012 11:17:33 +0200" Date: Thu, 02 Feb 2012 11:40:32 -0500 Message-ID: <25499.1328200832@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/37 X-Sequence-Number: 32380 Andrew Schetinin writes: > Previously I always thought that the order of JOINs or conditions in WHERE > is irrelevant, and query optimizer rearranges the order according to its > logic. Now it appears that sometimes it may be important. If you have more than join_collapse_limit JOINs in the query, the order can matter. regards, tom lane