Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1adiId-0005aJ-JP for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Mar 2016 17:53:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1adiId-0001uk-66 for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Mar 2016 17:53:31 +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) (envelope-from ) id 1adhLF-0006OC-4J for pgsql-bugs@postgresql.org; Wed, 09 Mar 2016 16:52:09 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1adhLA-0003L7-7d for pgsql-bugs@postgresql.org; Wed, 09 Mar 2016 16:52:07 +0000 MIME-Version: 1.0 Subject: BUG #14010: Multi-valued Index-only scans do not properly handle nulls in search To: pgsql-bugs@postgresql.org From: gtakahashi@palantir.com Date: Wed, 09 Mar 2016 16:51:36 +0000 Message-ID: <20160309165136.8903.83559@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" 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 The following bug has been logged on the website: Bug reference: 14010 Logged by: Glen Takahashi Email address: gtakahashi@palantir.com PostgreSQL version: 9.3.6 Operating system: Red Hat Enterprise Linux Server release 6.7 Description: Example table: a | b ---+-------- a | b a | [NULL] a | [NULL] (repeated 100's of times) b | a select a,b from test_table where (a,b) > ('a','a') order by a,b; returns: a | b ---+--- a | b b | a (2 rows) create index on test_table (a,b); The same query now returns: a | b ---+--- a | b (1 row) However, the query without using `order by` returns the right values! select a,b from test where (a,b) > ('a','a'); a | b ---+--- a | b b | a (2 rows) If there are sufficiently small enough number of nulls in between (I got differing numbers from 100-200 depending on the table), the query will instead use a Quicksort for what I can only assume is optimization to avoid reading random pages, and will actually return the right value. I was able to get this to reproduce 100% of the time when using > 256 nulls in between ('a','b') and ('b','a'); -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs