Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byemm-0002oA-Hc for pgsql-performance@arkaria.postgresql.org; Mon, 24 Oct 2016 12:55:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1byemm-0004if-17 for pgsql-performance@arkaria.postgresql.org; Mon, 24 Oct 2016 12:55:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1byel7-0002Hw-0J for pgsql-performance@postgresql.org; Mon, 24 Oct 2016 12:53:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1byejo-0007U3-AD for pgsql-performance@postgresql.org; Mon, 24 Oct 2016 12:52:25 +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 u9OCq8e5021211; Mon, 24 Oct 2016 08:52:09 -0400 From: Tom Lane To: Lars Aksel Opsahl cc: "pgsql-performance@postgresql.org" Subject: Re: Fast insert, but slow join and updates for table with 4 billion rows In-reply-to: References: ,<58dff6f9c2e64a8bb82a990ea1910d32@nibio.no> Comments: In-reply-to Lars Aksel Opsahl message dated "Mon, 24 Oct 2016 08:11:48 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21209.1477313528.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 24 Oct 2016 08:52:08 -0400 Message-ID: <21210.1477313528@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) 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 Lars Aksel Opsahl writes: > In this example I have two tables one with 4 billion rows and another wit= h 50000 rows and then I try to do a standard simple join between this two t= ables and this takes 397391 ms. with this SQL (the query plan is added is = further down) This particular query would work a lot better if you had an index on nora_bc25_observation (point_uid_ref, epoch), ie both join columns in one index. I get the impression that that ought to be the primary key of the table, which would be an even stronger reason to have a unique index on it. regards, tom lane --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance