Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XmQmM-0000iL-5V for pgsql-performance@arkaria.postgresql.org; Thu, 06 Nov 2014 17:23:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XmQmL-0007tz-I8 for pgsql-performance@arkaria.postgresql.org; Thu, 06 Nov 2014 17:23:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XmQmK-0007ts-G3 for pgsql-performance@postgresql.org; Thu, 06 Nov 2014 17:23:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XmQmC-0006Vm-Ic for pgsql-performance@postgresql.org; Thu, 06 Nov 2014 17:23:23 +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 sA6HNCOX010745; Thu, 6 Nov 2014 12:23:12 -0500 From: Tom Lane To: =?utf-8?Q?Art=C5=ABras?= Lapinskas cc: postgres performance list Subject: Re: Index order ignored after `is null` in query In-reply-to: <20141106170612.GA527@public-docking-cx-1226.ethz.ch> References: <20141105214243.GA546@public-docking-cx-1771.ethz.ch> <20141106170612.GA527@public-docking-cx-1226.ethz.ch> Comments: In-reply-to =?utf-8?Q?Art=C5=ABras?= Lapinskas message dated "Thu, 06 Nov 2014 18:06:12 +0100" Date: Thu, 06 Nov 2014 12:23:12 -0500 Message-ID: <10744.1415294592@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 =?utf-8?Q?Art=C5=ABras?= Lapinskas writes: > After some more investigation my wild guess would be that then nulls are > involved in query postgresql wants to double check whatever they are > really nulls in actual relation (maybe because of dead tuples). No, it's much simpler than that: IS NULL is not an equality operator, so it's not treated as constraining sort order. What you're asking for amounts to building in an assumption that "all nulls are equal", which is exactly not what the SQL semantics for NULL say. So I feel that you have probably chosen a bogus data design that is misusing NULL for a purpose at variance with the SQL semantics. That's likely to bite you on the rear in many more ways than this. Even disregarding the question of whether it's semantically appropriate, getting the planner to handle IS NULL this way would be a significant amount of work. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance