Index for range queries on JSON (user defined fields)

Поиск
Список
Период
Сортировка
От Marco Colli
Тема Index for range queries on JSON (user defined fields)
Дата
Msg-id CAFvCgN7Q0Ur2Gsrejai+Qsw=iz0pWBWhgZmNeu2455SGbSZzJg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Index for range queries on JSON (user defined fields)  (Nick Cleaton <nick@cleaton.net>)
Список pgsql-performance
Hello!

We have a multi-tenant service where each customer has millions of users (total: ~150M rows). Now we would like to let each customer define some custom columns for his users and then let the customer search his users efficiently based on these columns.

This problem seems really hard to solve with PostgreSQL:

In particular the easiest way would be to add a JSON field on the users table (e.g. user metadata). However the PostgreSQL GIN index only supports exact matches and not range queries. This means that a query on a range (e.g. age > 30) would be extremely inefficient and would result in a table scan.

Algorithmically it seems possible to use a GIN index (based on btree) for a range query. Also MongoDB seems to support something similar (https://docs.mongodb.com/manual/core/index-wildcard/).

Are there any plans to add support for range queries to GIN indexes (on JSON) in the future versions of PostgreSQL?


Marco Colli
Pushpad

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

Предыдущее
От: Riswana Rahman
Дата:
Сообщение: PostgeSQL JSONB Column with various type of data
Следующее
От: Michael Lewis
Дата:
Сообщение: Re: PostgeSQL JSONB Column with various type of data