Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etxfQ-0000xM-26 for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Mar 2018 15:41:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1etxfO-0000NU-C2 for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Mar 2018 15:41:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etxfO-0000NL-65 for pgsql-bugs@lists.postgresql.org; Thu, 08 Mar 2018 15:41:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etxfH-0001N2-48 for pgsql-bugs@lists.postgresql.org; Thu, 08 Mar 2018 15:41:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w28Ff4jJ012627; Thu, 8 Mar 2018 10:41:04 -0500 From: Tom Lane To: mehdirahbvd@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15102: Performance problem when doing join, index are not used In-reply-to: <152052183493.4972.11853150375334373737@wrigleys.postgresql.org> References: <152052183493.4972.11853150375334373737@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Thu, 08 Mar 2018 15:10:34 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12625.1520523664.1@sss.pgh.pa.us> Date: Thu, 08 Mar 2018 10:41:04 -0500 Message-ID: <12626.1520523664@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > Here is the query: > [ select with 11 input tables ] Perhaps raising join_collapse_limit to 11 or more would let the query planner find a better plan. Having said that, I see no especially good reason to think that sort-and-merge isn't a good join type for this query. Indexes aren't always the answer, especially not when joining large numbers of rows as you are here. Another direction to pursue is to raise work_mem to allow the sorts to proceed more efficiently. Don't go overboard on that, but judicious increases can help. Lastly, I see no reason whatever to think this is a bug. You might have better luck discussing the issue on the pgsql-performance list. regards, tom lane