#readwise # Indexes - LiteDB :: A .NET Embedded NoSQL Database ![rw-book-cover](https://readwise-assets.s3.amazonaws.com/static/images/article4.6bc1851654a0.png) ## Metadata - Author: [[litedb.org]] - Full Title: Indexes - LiteDB :: A .NET Embedded NoSQL Database - URL: http://www.litedb.org/docs/indexes/ ## Highlights ### Index Implementation - Insert and search operations have an average complexity of O(log n). This means that in a collection with 1 million documents, a search operation over an indexed expression will take about 13 steps to find the desired document. If you want to know more about skip lists, check this great video. - Given that collections are schema-less, it is possible for an expression to return different data types when applied over different documents. In such cases, the documents will be ordered by the type returned by the indexing expression ### `EnsureIndex()` - Indexes are created via `EnsureIndex`. This method creates the index if it does not exist and does nothing if already exists. An index can be created over any valid `BsonExpression`. - Limitations Even if multiple indexed expressions are used on a query, only one of the indexes is used, with the remaining expressions being filtered using a full scan. Index keys must occupy less than 1024 bytes Up to 255 indexes per collections, including the _id primary key, but limited to 8096 bytes for index definition. Each index uses: 41 bytes + LEN(name) + LEN(expression)