Index for range queries on JSON (user defined fields)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux