Re: [HACKERS] jsonb problematic operators

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] jsonb problematic operators
Дата
Msg-id 32168.1481901673@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] jsonb problematic operators  (Geoff Winkless <gwinkless@gmail.com>)
Список pgsql-hackers
Geoff Winkless <gwinkless@gmail.com> writes:
> To look at this from the other angle, is there a reason why the jsonb
> indexes don't work with the jsonb_ functions but only with the
> operators? Is this something that could be changed easily?

Yes.  No.  However, if you're desperate, you could make SQL wrapper
functions:

regression=# create function my_jsonb_exists(jsonb, text) returns bool
regression-# language sql as 'select $1 ? $2';
CREATE FUNCTION
regression=# create table foo(f1 jsonb);
CREATE TABLE
regression=# create index on foo using gin(f1);
CREATE INDEX
regression=# explain select * from foo where my_jsonb_exists(f1, 'bar');                              QUERY PLAN
                       
 
-------------------------------------------------------------------------Bitmap Heap Scan on foo  (cost=8.01..12.02
rows=1width=32)  Recheck Cond: (f1 ? 'bar'::text)  ->  Bitmap Index Scan on foo_f1_idx  (cost=0.00..8.01 rows=1
width=0)       Index Cond: (f1 ? 'bar'::text)
 
(4 rows)

This works because a simple SQL function like this will get inlined before
any interesting planning decisions are made.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: [HACKERS] background sessions
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Hang in pldebugger after git commit : 98a64d0