Re: PostgeSQL JSONB Column with various type of data

Поиск
Список
Период
Сортировка
От Michael Lewis
Тема Re: PostgeSQL JSONB Column with various type of data
Дата
Msg-id CAHOFxGrm-X0-mL+QyBkO=d3yjgCmSdFhCRCJ3Uf_dkWvfAGvEw@mail.gmail.com
обсуждение исходный текст
Ответ на PostgeSQL JSONB Column with various type of data  (Riswana Rahman <riswana@temenos.com>)
Список pgsql-performance
On Fri, Dec 4, 2020 at 9:21 AM Riswana Rahman <riswana@temenos.com> wrote:

CREATE OR REPLACE FUNCTION jsonbNull(jsonb_column JSONB)

returns boolean as $$

declare

              isPoint text := jsonb_typeof(jsonb_column) ;

begin                    

              CASE isPoint

                             WHEN 'array' THEN

                                           if  true = ALL(select (jsonb_array_elements(jsonb_column)) = '{}') THEN

                                                          return true;

                                           else

                                                           return false;

                                           end if;

                            WHEN 'object' THEN

                                           if jsonb_column = '{}' THEN

                                                          return true;

                                           else

                                                          return false;

                                           end if;

                             WHEN 'string' THEN

                                                          return false;

                             ELSE

                                           return true;

              END CASE;

end;

$$ LANGUAGE plpgsql IMMUTABLE;


As far as I can tell, it seems like this could be re-written as a function in SQL instead of plpgsql which allows for it to be in-lined. Have you tested performance and found it to be an issue, or just optimizing in advance of a need?

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

Предыдущее
От: Marco Colli
Дата:
Сообщение: Index for range queries on JSON (user defined fields)
Следующее
От: Nick Cleaton
Дата:
Сообщение: Re: Index for range queries on JSON (user defined fields)