Hello,
when I create a collection I have to create an index.
I found this
CREATE PRIMARY INDEX ON
default
:sf_bucket
.sf_scope
.products
and I found this:
CREATE PRIMARY INDEX idx_default_primary ON
travel-sample
USING GSI;
Hello,
when I create a collection I have to create an index.
I found this
CREATE PRIMARY INDEX ON
default
:sf_bucket
.sf_scope
.products
and I found this:
CREATE PRIMARY INDEX idx_default_primary ON
travel-sample
USING GSI;
You don’t have to create an index. But an index may help some queries, and may be necessary for others.
And you don’t have to create a primary index. It’s usually discouraged especially in production environments. For playing, it’s ok.
Your first index is on sf_bucket.sf_scope.products. (bucket.scope.collection)
Your second index is on travel-sample._default._default. (bucket.scope.collection).
primary index is “Storage: Standard GSI” by default.
So I have to use a normal index instead of a primary index like this:
CREATE INDEX idx_default_primary ON
travel-sample
USING GSI;
and for what is then primary index ? I think its like in a sql database the primary key so in sql this is important
Why do you think you have to create an index?
To retrieve documents by their key, use the kv api. It is much faster than the query api.
And when I have to join two tables ? then the query api is the have to ?
a. Creates the primary index with the default index name #primary:
CREATE PRIMARY INDEX ON default:sf_bucket.sf_scope.products
b. Create a named primary index. i.e the name of the primary index is ‘idx_default_primary’
CREATE PRIMARY INDEX idx_default_primary ON travel-sample USING GSI;
Refer:
Refer -
Refer: JOIN Clause | Couchbase Docs
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.