Byunggoo Kim
Byunggoo Kim

Reputation: 21

couchbase index for variable array in query

I tried to make and run some N1QL query that find document some field is matched with element of variable array in query. but speed of the query is too slow. The query is like below.

select * from bucket where tp='type' and tm between 1484618520 and 1484618615 and nm='name' and checked=false and (bucket.gm in ["TEST","TEST2"])

["TEST","TEST2"] part is variable depend on condition.

I want to speedup this query.

How can I create index for this query including variable array?

Thanks.

Upvotes: 0

Views: 165

Answers (1)

Byunggoo Kim
Byunggoo Kim

Reputation: 21

I solved this problem by using below command.

create index new_index on bucket(gm,tp,tm,nm,checked) using gsi;

I set the "gm" field as leading key of new index.

Then the query speed was totally improved.

Upvotes: 1

Related Questions