Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9J2R-0004HZ-AY for pgsql-general@arkaria.postgresql.org; Mon, 30 Oct 2017 23:00:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e9J2Q-0002l6-9N for pgsql-general@arkaria.postgresql.org; Mon, 30 Oct 2017 23:00:10 +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.84_2) (envelope-from ) id 1e9J02-0006ij-Nd for pgsql-general@postgresql.org; Mon, 30 Oct 2017 22:57:42 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e9Izz-0004Nx-Gz for pgsql-general@postgresql.org; Mon, 30 Oct 2017 22:57:42 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 1339C46A73; Mon, 30 Oct 2017 23:57:38 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id ILxIvovKpxXZ; Mon, 30 Oct 2017 23:57:35 +0100 (CET) Message-ID: <1509404254.3584.2.camel@cybertec.at> Subject: Re: query not scaling From: Laurenz Albe To: Rob Sargent Cc: "pgsql-general@postgresql.org" Date: Mon, 30 Oct 2017 23:57:34 +0100 In-Reply-To: <046d23a1-3748-8636-7e1a-e383cebff692@gmail.com> References: <6f7d4fd4-aed2-2fae-f551-d0f67196da33@gmail.com> <1509001363.2666.1.camel@cybertec.at> <30441.1509030087@sss.pgh.pa.us> <046d23a1-3748-8636-7e1a-e383cebff692@gmail.com> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On Thu, 2017-10-26 at 19:07 -0600, Rob Sargent wrote: >    ->  Nested Loop  (cost=3799.40..44686205.23 rows=1361304413 width=40) > (actual time=55.443..89684.451 rows=75577302 loops=1) >          ->  Hash Join  (cost=3798.98..43611.56 rows=823591 width=32) > (actual time=55.393..1397.509 rows=823591 loops=1) >          ->  Index Scan using marker_chrom_basepos_idx on base.marker m >   (cost=0.42..37.67 rows=1653 width=20) > (actual time=0.010..0.075 rows=92 loops=823591) > Index Cond: ((m.chrom = 22) AND (m.basepos >= s.startbase) AND (m.basepos <= s.endbase)) I think your biggest problem is the join condition on m.basepos between s.startbase and s.endbase That forces a nested loop join, which cannot be performed efficiently. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general