Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Creating An Index From A JSONB Column With An Object In An Array
Post Body

Hi folks!

So I have this JSON data structure:

{ "data": [ "account_id": "1234" .... ] }

In a table that is of a JSONB type column.

What's the best way to create an index where I can query account_id inside the array?

I tried doing this:

create index data_account_id_idx on foo using gin((jsonb_column->'data') jsonb_path_ops);

But when I run explain, it won't use the index. Any thoughts on what I'm doing wrong?

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
12,499
Link Karma
2,188
Comment Karma
10,210
Profile updated: 5 days ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago