pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: rj@rjewing.com
Subject: BUG #15861: jsonb exists query retuning inconsistent results
Date: Thu, 20 Jun 2019 01:49:58 +0000
Message-ID: <15861-fed7a8c85fffa2d7@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15861
Logged by:          RJ Ewing
Email address:      rj@rjewing.com
PostgreSQL version: 11.3
Operating system:   ubuntu 18.04
Description:        

When running the following query:

select count(*) from network_1.sample_photo where data ? 'photoID';

I am receiving inconsistent result that are different every time I run the
query. Somewhere in the 16k range. However I know for a fact that every row
in the table has a 'photoID' key. There are 103k rows.


The following query works correctly every time:

select count(*) from network_1.sample_photo where not data ?
data->>'photoID' is not null;



When running explain, the later is performing a seq scan, where as the
former has the following plan:

 Aggregate  (cost=409.55..409.56 rows=1 width=8) (actual time=44.498..44.499
rows=1 loops=1)
   ->  Bitmap Heap Scan on sample_photo  (cost=20.80..409.29 rows=103
width=0) (actual time=7.008..35.916 rows=16431 loops=1)
         Recheck Cond: (data ? 'photoID'::text)
         Heap Blocks: exact=9932
         ->  Bitmap Index Scan on idx_network_1_sample_photo_data 
(cost=0.00..20.77 rows=103 width=0) (actual time=5.273..5.274 rows=16431
loops=1)
               Index Cond: (data ? 'photoID'::text)

The index "idx_network_1_sample_photo_data" is a gin index.


I am not able to reproduce this on my local machine. This problem happened
in version 10, and I just upgraded to 11 without any improvement. I tried a
vaccum full analyze & to rebuild the table indexes.

Is this a bug? Or am I missing something?

Thanks in advance



view thread (4+ messages)  latest in thread

Message-ID: <15861-fed7a8c85fffa2d7@postgresql.org>
Permalink:  ../15861-fed7a8c85fffa2d7@postgresql.org/
Also on:    postgresql.org/message-id/15861-fed7a8c85fffa2d7@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, rj@rjewing.com
  Subject: Re: BUG #15861: jsonb exists query retuning inconsistent results
  In-Reply-To: <15861-fed7a8c85fffa2d7@postgresql.org>
  References: <15861-fed7a8c85fffa2d7@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox