You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Couchbase Query Service makes use of xref:7.1@server:learn:services-and-indexes/indexes/indexes.adoc[_indexes_] in order to do its work.
26
+
The Couchbase Query Service makes use of xref:{version-server}@server:learn:services-and-indexes/indexes/indexes.adoc[_indexes_] in order to do its work.
27
27
Indexes replicate subsets of documents from data nodes over to index nodes,
28
28
allowing specific data (for example, specific document properties) to be retrieved quickly,
29
-
and to distribute load away from data nodes in xref:7.1@server:learn:services-and-indexes/services/services.adoc[MDS] topologies.
29
+
and to distribute load away from data nodes in xref:{version-server}@server:learn:services-and-indexes/services/services.adoc[MDS] topologies.
30
30
31
-
[IMPORTANT]
32
-
In order to make a bucket queryable, it must have at least one index defined.
31
+
=== Query without Index
32
+
33
+
From Couchbase Server 7.6 onwards,
34
+
CRUD operations (such as `CREATE`, `INSERT`, and `SELECT`) and `JOIN` can be performed against the Query Service without an index (primary or secondary).
35
+
This uses a xref:server:learn:services-and-indexes/indexes/query-without-index.adoc#sequential-scans[sequential scan], relying on a KV range scan to deliver the keys.
36
+
37
+
Sequential scans are best suited to small collections where key order is unimportant, or where the overhead of maintaining an index can't be justified.
38
+
For larger collections and greater performance, define the appropriate indexes to speed up your queries.
39
+
For ordered document key operations, a primary index provides the same functionality, and will outperform a sequential scan.
40
+
41
+
Creating the right index, with the right keys, right order, and right expression is critical to query performance in any database system.
42
+
A Primary Index on the document keys will give you better search performance than trying to query without index,
43
+
but well-chosen secondary indexes will make all the difference to query performance.
44
+
45
+
=== Defining an Index
33
46
34
47
You can define a _primary index_ on a bucket.
35
48
When a _primary_ index is defined you can issue non-covered (see below) queries on the bucket as well.
@@ -59,7 +72,7 @@ Indexes help improve the performance of a query.
59
72
When an index includes the actual values of all the fields specified in the query,
60
73
the index _covers_ the query, and eliminates the need to fetch the actual values from the Data Service.
61
74
An index, in this case, is called a _covering index_, and the query is called a _covered_ query.
62
-
For more information, see xref:7.1@server:n1ql:n1ql-language-reference/covering-indexes.adoc[Covering Indexes].
75
+
For more information, see xref:{version-server}@server:n1ql:n1ql-language-reference/covering-indexes.adoc[Covering Indexes].
63
76
64
77
You can also create and define indexes in the SDK using:
65
78
@@ -125,7 +138,7 @@ and allows optimization on a case-by-case basis.
125
138
126
139
== Collections and Scopes, and the Query Context
127
140
128
-
From Couchbase Server release 7.0 the xref:7.1@server:learn:data/scopes-and-collections.adoc[Collections] feature lets you logically group similar documents into Collections.
141
+
From Couchbase Server release 7.0 the xref:{version-server}@server:learn:data/scopes-and-collections.adoc[Collections] feature lets you logically group similar documents into Collections.
129
142
130
143
You can query collections in {sqlpp}, by referring to a fully qualified keyspace.
131
144
For example, to list the documents in the `airline` collection in the `inventory` scope:
@@ -135,7 +148,7 @@ For example, to list the documents in the `airline` collection in the `inventory
135
148
SELECT * FROM `travel-sample`.inventory.airline;
136
149
----
137
150
138
-
As a convenience, you can also query a partial keyspace from the xref:7.1@server:n1ql:n1ql-intro:sysinfo.adoc#query-context[Query Context] of a specific Scope.
151
+
As a convenience, you can also query a partial keyspace from the xref:{version-server}@server:n1ql:n1ql-intro:sysinfo.adoc#query-context[Query Context] of a specific Scope.
139
152
For example, from the context of `{backtick}travel-sample{backtick}.inventory`, you could abbreviate the previous query to:
0 commit comments