Indexes

Every MongoDB index type, global and updated in the same write as the document.

TeselaDB has every MongoDB index type: single field, compound, multikey, unique, partial, sparse, hidden, TTL, with collation, hashed, wildcard, 2dsphere and 2d. Text indexes are in Search.

JavaScript
db.orders.createIndex({ customer: 1, created: -1 });
db.users.createIndex({ email: 1 }, { unique: true });
db.sessions.createIndex({ lastSeen: 1 }, { expireAfterSeconds: 3600 });

Global indexes

Every index is global: its entries are kept sorted in the same key space as the documents and are written in the same operation. If the document and its index entry fall in the same range, the write is single-phase; if not, it goes in a transaction. You never see an index that does not match its documents.

Uniqueness across the cluster

A unique index is unique across the whole cluster, also in a collection with a shard key and without that key as a prefix. MongoDB only guarantees uniqueness within each shard.

Increasing keys

An index on a value that always grows (a date, a counter) concentrates writes on the last range. TeselaDB's own option teselaBuckets spreads its entries over hash buckets; the planner merges the buckets on read:

JavaScript
db.events.createIndex({ created: 1 }, { teselaBuckets: 8 });

Online builds

createIndexes builds the index without stopping the writes to the collection, and collMod changes hidden, expireAfterSeconds or unique on an existing index.