Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dCp5f-0005lS-Qh for pgsql-performance@arkaria.postgresql.org; Mon, 22 May 2017 15:17:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dCp5e-0002bQ-RE for pgsql-performance@arkaria.postgresql.org; Mon, 22 May 2017 15:17:46 +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 1dCp5c-0002ai-PD for pgsql-performance@postgresql.org; Mon, 22 May 2017 15:17:44 +0000 Received: from resqmta-ch2-02v.sys.comcast.net ([2001:558:fe21:29:69:252:207:34]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dCp5V-00051r-9p for pgsql-performance@postgresql.org; Mon, 22 May 2017 15:17:43 +0000 Received: from resomta-ch2-09v.sys.comcast.net ([69.252.207.105]) by resqmta-ch2-02v.sys.comcast.net with SMTP id Cp4vdwDoUBHfPCp5RdI8Al; Mon, 22 May 2017 15:17:33 +0000 Received: from cherryberry.dsgml.com ([IPv6:2601:547:500:4c15:22cf:30ff:fe05:22e8]) by resomta-ch2-09v.sys.comcast.net with SMTP id Cp5QdqIwyjCS0Cp5RdUuX9; Mon, 22 May 2017 15:17:33 +0000 Received: from as (helo=localhost) by cherryberry.dsgml.com with local-esmtp (Exim 4.84_2) (envelope-from ) id 1dCp5P-0000dL-V0 for pgsql-performance@postgresql.org; Mon, 22 May 2017 11:17:32 -0400 Date: Mon, 22 May 2017 11:17:31 -0400 (EDT) From: Ariel X-X-Sender: as@cherryberry.dsgml.com To: pgsql-performance@postgresql.org Subject: index of only not null, use function index? Message-ID: User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-CMAE-Envelope: MS4wfAw14i6tQsVDmWPR8pAAEjGyRweF99shPvZTIyNBdcl4GTO9sRQcGEWFcrRCh6pGIbCL0525Ynln25ELWBPYFXWLSfJP/gyhf2xF2h7VORuvMSER72/Q oQxaLuL72YcYrkc4P4ZL0oqQw+CRzn/Gt2AkETdb6vf8G3xHCM2Vbt0ctm33zksP5UvLKy98K7F21w== X-Pg-Spam-Score: -2.6 (--) 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 I need to be able to quickly find rows where a column is not null (only a small percent of the rows will have that column not null). Should I do: CREATE INDEX ON table ((col IS NOT NULL)) WHERE col IS NOT NULL or: CREATE INDEX ON table (col) WHERE col IS NOT NULL I'm thinking the first index will make a smaller, simpler, index since I don't actually need to index the value of the column. But are there any drawbacks I may not be aware of? Or perhaps there are no actual benefits? -Ariel -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance