Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hudqm-0005lM-9b for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2019 14:20:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hudql-0005mg-6r for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2019 14:20:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hudqk-0005mZ-QK for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2019 14:20:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hudqi-0006TU-JS for pgsql-general@postgresql.org; Mon, 05 Aug 2019 14:20:33 +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 x75EKURb012590; Mon, 5 Aug 2019 10:20:30 -0400 From: Tom Lane To: Jeremy Finzel cc: Postgres General Subject: Re: Aggregate not using BRIN index on timestamp In-reply-to: References: Comments: In-reply-to Jeremy Finzel message dated "Mon, 05 Aug 2019 08:45:47 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12588.1565014830.1@sss.pgh.pa.us> Date: Mon, 05 Aug 2019 10:20:30 -0400 Message-ID: <12589.1565014830@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jeremy Finzel writes: > I have a very large table with 4 billion rows and a BRIN index on timestamp > spanning from 2013 to present. I am running this simple query: > SELECT MIN(created_at) FROM table; > It is choosing a parallel seq scan as opposed to a BRIN bitmap scan. > I can provide more info. But first - am I missing something obvious? Yes: BRIN indexes don't provide any ordering information. A btree index on created_at could be used to optimize this query, but without one of those, seqscanning the whole table is the only possibility. regards, tom lane