Is index being used when JSONB field is queried by range operators like < or > ?

Hi team,

I’m using this version of CRDB: build: CCL v20.1.4 @ 2020/07/29 22:56:36 (go1.13.9)

Created a table with a JSONB type column, created inverted index, then inserted a few rows.

create table t (id int, attrs jsonb);
create index t_idx on t using gin (attrs);
insert into t (id, attrs) values (1, '{"n": 1, "s": "a"}'), (2, '{"n": 2, "s": "b"}'), (11, '{"n": 11, "s": "c"}'), (12, '{"n": 12, "s": "d"}');

Then I ran a query like below with a range operator GT (>) :

select * from t where (attrs->>'n')::int > 11;

I’m wondering if that query leverages the inverted index or not. It’s fast enough when dataset size is tiny, but little bit concerned when there are a lot of rows.

Appreciate your help!

Deleting this post in favor of this: How to use index in case of range operators (>, <, etc.) with jsonb column?

OK, seems I can’t delete the post.