mongodb索引长度限制

本文介绍了MongoDB中索引的一些重要限制,包括每个集合索引的数量不得超过64个,索引名称长度限制为128个字符,以及复合索引中字段数量的上限为31个。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mongodb索引长度限制

集合中索引不能超过64个
索引名的长度不能超过128个字符
一个复合索引最多可以有31个字段
可以使用db.collection.ensureIndex({indexName:1},{name:”xxxIndexName”})指定name的长度。

Number of Indexes per Collection
A single collection can have no more than 64 indexes.
Index Name Length

Fully qualified index names, which includes the namespace and the dot separators (i.e. ..$), cannot be longer than 128 characters.

By default, is the concatenation of the field names and index type. You can explicitly specify the to the createIndex() method to ensure that the fully qualified index name does not exceed the limit.

Number of Indexed Fields in a Compound Index
There can be no more than 31 fields in a compound index.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值