Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cu2YE-0000ch-LZ for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Mar 2017 19:49:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cu2YD-00024U-S2 for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Mar 2017 19:49:37 +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 1cu2YD-00024K-Dk for pgsql-bugs@postgresql.org; Fri, 31 Mar 2017 19:49:37 +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.84_2) (envelope-from ) id 1cu2YB-00069X-0h for pgsql-bugs@postgresql.org; Fri, 31 Mar 2017 19:49:36 +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 v2VJnQ87015735; Fri, 31 Mar 2017 15:49:26 -0400 From: Tom Lane To: Andrew Gierth cc: lucas@lucas-nussbaum.net, pgsql-bugs@postgresql.org Subject: Re: BUG #14608: no index scan with NOT IN and ENUM In-reply-to: <874ly95ky8.fsf@news-spur.riddles.org.uk> References: <20170331185301.2690.64421@wrigleys.postgresql.org> <874ly95ky8.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Fri, 31 Mar 2017 20:04:04 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15733.1490989766.1@sss.pgh.pa.us> Date: Fri, 31 Mar 2017 15:49:26 -0400 Message-ID: <15734.1490989766@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Andrew Gierth writes: > "lucas" == lucas writes: > lucas> I would expect postgresql to figure out that "not in ('1', '2', > lucas> '3', '4')" is equivalent to "d = '0'" given that the column is > lucas> NOT NULL. And use the index. > Well, whatever you expect, nobody has ever written code for the planner > to make it figure that out (and it doesn't seem likely to be a major > win, so probably not surprising that nobody did it). TBH, even if someone submitted a patch that did that, it would probably get rejected on the grounds that it consumed too many cycles in cases where it failed to yield a win --- which would be most of the time. Another problem is that ALTER TYPE ADD VALUE would have to invalidate plans depending on such a deduction. The infrastructure needed to cope with that would add still more distributed overhead, which would be paid by everybody whether or not they ever issued a query that could benefit. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs