pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15861: jsonb exists query retuning inconsistent results
4+ messages / 3 participants
[nested] [flat]
* BUG #15861: jsonb exists query retuning inconsistent results
@ 2019-06-20 01:49 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 4+ messages in thread
From: PG Bug reporting form @ 2019-06-20 01:49 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: rj@rjewing.com
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #15861: jsonb exists query retuning inconsistent results
@ 2019-06-20 06:56 Sergei Kornilov <sk@zsrv.org>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 4+ messages in thread
From: Sergei Kornilov @ 2019-06-20 06:56 UTC (permalink / raw)
To: rj@rjewing.com <rj@rjewing.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hello
Please check your gin_fuzzy_search_limit setting: https://www.postgresql.org/docs/current/gin-tips.html
Seems this setting is in effect.
regards, Sergei
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #15861: jsonb exists query retuning inconsistent results
@ 2019-06-20 13:48 RJ Ewing <rj@rjewing.com>
parent: Sergei Kornilov <sk@zsrv.org>
0 siblings, 1 reply; 4+ messages in thread
From: RJ Ewing @ 2019-06-20 13:48 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>; Sergei Kornilov <sk@zsrv.org>
Ya, that is most likely the issue. I have the gin_fuzzy_search_limit set to 15k.
Is there a way around this? Having a search limit of 15k seems reasonable to me when doing a FTS, however I would not want that limit when doing an exists query. Any way to tell the planner to not use the index? Or other alternative?
Thanks
RJ Ewing
On Jun 19, 2019, 11:56 PM -0700, Sergei Kornilov <sk@zsrv.org>, wrote:
> Hello
>
> Please check your gin_fuzzy_search_limit setting: https://www.postgresql.org/docs/current/gin-tips.html
> Seems this setting is in effect.
>
> regards, Sergei
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #15861: jsonb exists query retuning inconsistent results
@ 2019-06-20 13:53 Sergei Kornilov <sk@zsrv.org>
parent: RJ Ewing <rj@rjewing.com>
0 siblings, 0 replies; 4+ messages in thread
From: Sergei Kornilov @ 2019-06-20 13:53 UTC (permalink / raw)
To: RJ Ewing <rj@rjewing.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hi
gin_fuzzy_search_limit is just PGC_USERSET setting. You can change it anytime with SET command, for example for concrete transaction:
begin;
set local gin_fuzzy_search_limit to 0; -- zero is default value
/* some queries */
commit;
regards, Sergei
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2019-06-20 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20 01:49 BUG #15861: jsonb exists query retuning inconsistent results PG Bug reporting form <noreply@postgresql.org>
2019-06-20 06:56 ` Sergei Kornilov <sk@zsrv.org>
2019-06-20 13:48 ` RJ Ewing <rj@rjewing.com>
2019-06-20 13:53 ` Sergei Kornilov <sk@zsrv.org>
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