How to Start SequoiaDB

Basic Operation

Data Model

Database Management








Release Note


  • Content
  • Comments
  • History



In SequoiaDB database, indexes are a kind of special objects. Instead of being used to store user data, indexes, a kind of special metadata, optimize speed and performance in finding relevant documents for a search query.

Every index is put in a colleciotn. A collection contains 64 indexes at most.

Indexing is regarded as an approach to sort data based on one or more fields, and rapidly get results which match users' query statements from it as soon as queries are submitted. In SequoiaDB, indexes are stored in structures called B-trees.

A typical index structure is as follow:

In this figure, the data is on the left, the indexes are on the right in the triangle. Indexes are sorted in the structure of trees in ascending order. every document will have a unique index value.

Through tree tranversal, the position of specific data can be rapidly found.

SequoiaDB can create indexes to any type of data. An index contains:

Attribute Description
name Index name. Index name is unique in a collection.
key Index key, as a JSON object, contains one or multiple indexes field and direction field. If direction field is 1 or -1, the order is ascending or descending.
unique "Unique", a optonal parameter, shows that whether an index is unique. The default value of it is "false". When its value is "true", the index is unique. As for unique index, there should not be repetitive records in a collection.
enforced "Enforced" shows that whether an index is enforced to be unique. The default value is "false". If its value is "true", with "unique" set "true", there is no more than one null index key.

In SequoiaDB, every collection contains an enforced unique index named "$id". The index contains a index key of "_id".

An index named "$shard" is automatically is generated when sharding collection is created. The index key of it is the sharding key specified by users.


In sharding collection, all unique indexes should contain all the fields specified by collection sharding key.

In sharding collection, "$id" index merely ensure the uniqueness of records within a single node. If users plan to create a globally unique field, they have to create an extra unique field, which contains all the fileds specified by collection sharding key.


The format of index contains two fields: "name" and "key". The type of "name" is string. The type of "key" is JSON object.

{ "name" : "index name", "key" : "{ 'index field1' : direction ['index field2' : direction ...] }",[ 'unique' : true|false ], [ 'enforced' : true|false ] }

The object of "key" contains at least one field. The field name of it is the field name that user search for. Its value is "1" or "-1". "1" represents ascending sequence of data. "-1" represents descending sequence of data.


  • Non-unique index, index name: "employee_id_key", index field is forward "employee_id".

    { "name" : "employee_id_key", "key" : { "employee_id" : 1 } }
  • Unique index, index name is "record_id_index", index field is forward "product_key" and reverse "record_key".

    { "name" : "record_id_index", "key" : { "product_key" : 1, "record_key" : -1 }, "unique" : true }

    In this index, there are no two records with the same "product_key" and the same "record_key". (But if either of them is the same, it is still regarded as an unique index.)

  • Enforced unique index. The index name is "test index". The index field is ascending "test case name".

    { "name" : "test index", "key" : { "test case name" : 1 }, "unique" : true, "enforced" : true }

    In an enforced unique index, all records should follow the rule of unique index. There should not be more than one record that contains a null value of "test case name" field.

please login to comment.
Latest Comment
  • 2015-02-14

About Us

SequoiaDB is a financial-level distributed database vendor and is the first Chinese database listed in Gartner’s Magic Quadrant OPDBMS report. SequoiaDB has recently released version 3.0.
SequoiaDB is now penetrating the vertical sector Financial Industry quickly and had more than 50 banking clients and hundreds of enterprise customers in industries including government, telecommunication, Internet and IoT.

Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Tsing Hua Tech Park, Nanshan District, Shenzhen,China