Create Index
Table of Contents
An index stores the values of one or more fields of every document in a schema, so that queries can find documents by those values without reading the whole schema. A unique key (UNIQUEKEY) is an index that also rejects documents whose values already exist in the schema.
CREATE INDEX IndexName (Field1 [, Field2 ...]) ON Schema
CREATE UNIQUEKEY IndexName (Field1 [, Field2 ...]) ON SchemaCreating an index indexes the documents already in the schema. From then on, inserts, updates and deletes keep it up to date in the same transaction. Requires the Manage permission on the schema.
- A condition that compares an indexed field to a value with = is answered from the index.
- A composite index is used when its leading fields are compared with =. When every field of a unique key is compared, the lookup is a single key read.
- When several conditions can each use an index, the results of the indexes are intersected.
- The management UI's Explain Plan button (and the client API's ExplainPlan) shows which indexes a query will use, and suggests CREATE INDEX statements for conditions that would otherwise read every document.
CREATE INDEX IX_Word_Text
(
Text
) ON WordList:WordCREATE INDEX IX_Word_LanguageId_Text
(
LanguageId,
Text
) ON WordList:WordCREATE UNIQUEKEY UK_Language_Id
(
Id
) ON WordList:LanguageRemoved options
The WITH (Partitions = n) option is still accepted but is ignored, see Partitions.Home
The home page
SQL :: Alter Index
Creates and drops indexes and unique keys.
SQL :: Analyze Index
Reports the statistics of an index.
SQL :: Analyze Schema
Reports the size of a schema's documents and the statistics of its indexes.
SQL :: Attach Schema
Copies a detached schema (namespace) into the database.
SQL :: Insert
Insert creates new documents in a schema.
SQL :: Keywords
A breakdown of all of the statements and keywords supported by the query processor.
SQL :: Partitions
Removed: index partitions no longer apply.
SQL :: Rebuild Index
Rebuilds an index from the documents in its schema.
SQL :: Where
The where clause filters the documents read, updated or deleted by a statement.