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
Copy file name to clipboardExpand all lines: modules/ROOT/pages/_partials/commons/common-indexing.adoc
+6-7Lines changed: 6 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -25,19 +25,18 @@
25
25
//:this-url-issues: {par-url-issues}
26
26
// END::REQUIRED EXTERNALS
27
27
28
-
.Constraints
29
-
NOTE:
30
-
Couchbase Lite for {param-platform} does not currently supported partial value indexes; that is, indexes with non property expressions.
31
-
You should only index with properties that you plan to use in the query.
32
-
33
-
34
28
== Introduction
35
-
29
+
// tag::overview[]
36
30
Before we begin querying documents, let's briefly mention the importance of having an appropriate and balanced approach to indexes.
37
31
38
32
Creating indexes can speed up the performance of queries.
39
33
A query will typically return results more quickly if it can take advantage of an existing database index to search, narrowing down the set of documents to be examined.
The Query optimizer converts your query into a parse tree that groups zero or more _and-connected_ clauses together (as dictated by your `where` conditionals) for effective query engine processing.
@@ -163,6 +164,22 @@ Less good is if the query must scan the whole index; although the compact nature
163
164
164
165
Searches that begin with or rely upon an inequality with the primary key are inherently less effective than those using a primary key equality.
165
166
167
+
== Working with the Query Optimizer
168
+
You may have noticed that sometimes a query runs faster on a second run, or after re-opening the database, or after deleting and recreating an index.
169
+
This typically happens when SQL Query Optimizer has gathered sufficient stats to recognize a means of optimizing a sub-optimal query.
170
+
171
+
If only those stats were available from the start.
172
+
In fact they are gathered after certain events, such as:
173
+
174
+
* Following index creation
175
+
* On a database close
176
+
* When running a database compact.
177
+
178
+
So, if your analysis of the <<qe-output, Query Explain output>> indicates a sub-optimal query and your rewrites fail to sufficiently optimize it, consider compacting the database.
179
+
Then re-generate the Query Explain and note any improvements in optimization.
180
+
They may not, in themselves, resolve the issue entirely; but they can provide a uesful guide toward further optimizing changes you could make.
Knowing this, you can consider how you create the index; for example, using {url-api-method-function-lower} when you create the index and then always using lowercase comparisons.
259
276
260
277
== Optimization Considerations
278
+
261
279
Try to minimize the amount of data retrieved.
262
280
Reduce it down to the few properties you really *do* need to achieve the required result.
0 commit comments