We have the following json documents stored in our PG table (identities) in a jsonb column 'data':
{
"email": {
"main": "[email protected]",
"prefix": "aliasPrefix",
"prettyEmails": ["stuff1", "stuff2"]
},
...
}
I have the following index set up on the table:
CREATE INDEX ix_identities_email_main
ON identities
USING gin
((data -> 'email->main'::text) jsonb_path_ops);
What am I missing that is preventing the following query from hitting that index?? It does a full seq scan on the table... We have tens of millions of rows, so this query is hanging for 15+ minutes...
SELECT * FROM identities WHERE data->'email'->>'main'='[email protected]';
data @> '{"email": {"main": "[email protected]"}}'
But that not only misses the index as well, it isn't really the query I want anyways because of the other properties on the email object. – Wes Tyler Dec 18 '15 at 18:09EXPLAIN ...
)? – user3137702 Dec 18 '15 at 18:23" Filter: (((data -> 'email'::text) ->> 'main'::text) = '[email protected]'::text)"
– Wes Tyler Dec 18 '15 at 19:31