Skip to main content
1 of 3
Evan Carroll
  • 64.7k
  • 49
  • 251
  • 496

GIN indexes do not work with any jsonb operators EXCEPT ? ?& ?| @>. Clearly, your use of comparison operators >= and <= are not on that list. And all of those operators that it could help are also not on the list (meaning the index won't do anything) afaik.

That means needing indexed comparison operators, you'll need a btree.

CREATE INDEX ON public.influencers ((ig->'follower_count'));

All of that said, I think this is silly. Just denormalize and put follower_count on the actual table and enjoy the performance benefits.

Evan Carroll
  • 64.7k
  • 49
  • 251
  • 496